CS23231-Data Structure - 2mark (Unit I - III)
CS23231-Data Structure - 2mark (Unit I - III)
1
• Linked list can grow and shrink in size depending upon the insertion and deletion that
occurs in the list
• Insertions and deletions at any place in a list can be handled easily and efficiently
• A linked list does not waste any memory space
2
• It is easier for several people to work on a modular program simultaneously
• A well-written modular program places certain dependencies in only
one routine, making changes easier
3
UNIT II - LINEAR DATA STRUCTURES – STACKS, QUEUES
4. Define a stack
Stack is an ordered collection of elements in which insertions and deletions are
restricted to one end. The end from which elements are added and/or removed is referred
4
to as top of the stack. Stacks are also referred as piles, push-down lists and last-in-first-
out (LIFO) lists.
5
9. Mention the advantages of representing stacks using linked lists than arrays
• It is not necessary to specify the number of elements to be stored in a stack during its
declaration, since memory is allocated dynamically at run time when an element is added
to the stack
• Insertions and deletions can be handled easily and efficiently
• Linked list representation of stacks can grow and shrink in size without wasting
memory space, depending upon the insertion and deletion that occurs in the list
• Multiple stacks can be represented efficiently using a chain for each stack
7
UNIT III – NON LINEAR DATA STRUCTURES – TREES
1. Define a tree
A tree is a collection of nodes. The collection can be empty; otherwise, a tree consists of a
distinguished node r, called the root, and zero or more nonempty (sub) trees T1, T2,…,Tk, each
of whose roots are connected by a directed edge from r.
2. Define root
This is the unique node in the tree to which further sub-trees are attached.
4. Define leaves
These are the terminal nodes of the tree. The nodes with degree 0 are always the
leaves.
8
5. Define internal nodes
The nodes other than the root and the leaves are called internal nodes.
9
10. Define forest
A tree may be defined as a forest in which only a single node (root) has no
predecessors. Any forest consists of a collection of trees.
11
22. State the merit of linked representation of binary trees.
Insertions and deletions in a node involve no data movement except the
rearrangement of pointers, hence less processing time.
26. Traverse the given tree using Inorder, Preorder and Postorder traversals.
Inorder : D H B E A F C I G J
12
Preorder: A B D H E C F G I J
Postorder: H D E B F I J G C A
27. In the given binary tree, using array you can store the node 4 at which location?
At location 6
1 2 3 - - 4 - - 5
where LCn means Left Child of node n and RCn means Right Child of node n
14
Right-Left: The newly inserted node is in the left subtree of the right child of A.
15
16