Wednesday, December 14, 2011

Sorted Array/Linked List to Balanced BST & BST to Circular Doubly Linked List

1st Question: Sorted Array to BST


Examples:
Input:  Array {1, 2, 3} or 1->2->3
Output: A Balanced BST
     2
   /  \
  1    3 

Input: Array {1, 2, 3, 4} or 1->2->3->4
Output: A Balanced BST
      3
    /  \
   2    4
 /
1

http://www.geeksforgeeks.org/sorted-array-to-balanced-bst/
http://www.geeksforgeeks.org/sorted-linked-list-to-balanced-bst/


Also
1.Convert Sorted Doubly Linked List to Binary Tree- http://discuss.joelonsoftware.com/default.asp?interview.11.465953.9
 
Usage:
1.BST to Min-Heap
http://www.geeksforgeeks.org/in-place-convert-bst-into-a-min-heap/
2.Merge 2 BSTs
http://www.geeksforgeeks.org/merge-two-balanced-binary-search-trees/

2nd Question: BST/BT to Circular Doubly Linked List


http://articles.leetcode.com/convert-binary-search-tree-bst-to/
http://www.geeksforgeeks.org/in-place-convert-a-given-binary-tree-to-doubly-linked-list/
http://www.geeksforgeeks.org/convert-a-given-binary-tree-to-doubly-linked-list-set-2/
http://www.geeksforgeeks.org/convert-given-binary-tree-doubly-linked-list-set-3/


Also

1. Convert a BST to circular sorted linked list-http://www.careercup.com/question?id=123685

1 comment:

  1. http://tech-queries.blogspot.com/2008/12/level-order-tree-traversal-in-reverse.html

    ReplyDelete