Marketing Mix of Alcoholic Beverage Companies

Only available on StudyMode
  • Topic: Linked list, Array data structure, Reference
  • Pages : 4 (606 words )
  • Download(s) : 557
  • Published : March 28, 2012
Open Document
Text Preview

Question 1

a) Two criteria that must be followed in constructing a binary tree so that it is complete.

-each node that has any children has exactly two children.

-the depth should be equal in both sides

b) Binary tree that satisfies max-heap property. (7,10,3,11,5,4,1,2,1,0,8)Values inserted into tree in the order given and tree is reorganized every time an item is added.

c) Given the following(10,30,74,63,2,65,5,21,97,64) construct a binary search tree. Values inserted in the tree in the order given.

d) Give the output of a pre-order traversal of the tree above.

NO IDEA

Question 2

a) What are the advantages and disadvantages of singly linked list over doubly linked list?

Advantages

1. Is a recursive data structure, because it contains a pointer to a smaller object of the same type. For that reason, many operations on singly linked linear list (such as merging two lists, or enumerating the elements in reverse order) often have very simple recursive algorithms, much simpler than any solution using iterative commands.

1. Linear singly linked lists also allow tail-sharing. This is the use of a common final portion of sub-list as the terminal portion of two different lists. In particular, if a new node is added at the beginning of a list, the former list remains available as the tail of the new one.

Disadvantages

1. They are not easy to manipulate, this is because they do not allow sequential access to the list in both directions like doubly linked list. For example In a doubly linked list, one can insert or delete a node in a constant number of operations given only that node's address but to do the same in a singly linked list, one must have the address of the pointer to that node, which is either the handle for the whole list (in case of the first node) or the link field in the previous node....
tracking img