-
Answer :
A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other. Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of data.
-
Answer :
It must rich enough in structure to reflect the actual relationship of data in real world. The structure should be simple enough for efficient processing of data.
-
Answer :
STACK:
i) Stack is a ordered collection of items.
ii) Stack is a dynamic object whose size is constantly changing as items are pushed and popped.
iii) Stack may contain different data types.
iv) Stack is declared as a structure containing an array to hold the element of the stack, and an integer to indicate the current stack top within the array.
ARRAY:
i) Array is an ordered collection of items.
ii) Array is a static object i.e. no of item is fixed and is assigned by the declaration of the array.
iii) It contains same data types.
iv) Array can be home of a stack i.e. array can be declared large enough for maximum size of the stack.
-
Answer :
The definition which defines an object in terms of simpler cases of itself is called recursive definition.
-
Answer :
In sequential search each item in the array is compared with the item being searched until a match occurs. It is applicable to a table organized either as an array or as a linked list.
-
Answer :
When a function is called
i) arguments are passed.
ii) local variables are allocated and initialized.
ii) transferring control to the function.
-
Answer :
i) Return address is retrieved.
ii) Function’s data area is freed.
iii) Branch is taken to the return address.
-
Answer :
A linked list is a linear collection of data elements, called nodes, where the linear order is given by pointers. Each node has two parts first part contain the information of the element second part contains the address of the next node in the list.
-
Answer :
It is a technique in which the operating system periodically collects all the deleted space onto the free storage list.
It takes place when there is minimum amount of space left in storage list or when CPU is ideal.
The alternate method to this is to immediately reinsert the space into free storage list which is time consuming.
-
Answer :
When new data is to be inserted into the data structure but there is no available space i.e. free storage list is empty this situation is called overflow.
When we want to delete data from a data structure that is empty this situation is called underflow
-
Answer :
i) The no of nodes needed can’t be predicted when the program is written.
ii) The no of nodes declared must remain allocated throughout its execution.
-
Answer :
A queue is an ordered collection of items from which items may be deleted at one end (front end) and items inserted at the other end (rear end).
It obeys FIFO rule there is no limit to the number of elements a queue contains
-
Answer :
The priority queue is a data structure in which the intrinsic ordering of the elements (numeric or alphabetic)
Determines the result of its basic operation. It is of two types:
i) Ascending priority queue- Here smallest item can be removed (insertion is arbitrary).
ii) Descending priority queue- Here largest item can be removed (insertion is arbitrary)
-
Answer :
i) A node in a linked list (info and next field) occupies more storage than a corresponding element in an array.
ii) Additional time spent in managing the available list
-
Answer :
After a call to free(p) makes a subsequent reference to *p illegal, i.e. though the storage to p is freed but the value of p(address) remain unchanged .so the object at that address may be used as the value of *p (i.e. there is no way to detect the illegality).Here p is called dangling pointer.
To avoid this it is better to set p to NULL after executing free(p).The null pointer value doesn’t reference a storage location it is a pointer that doesn’t point to anything.
-
Answer :i) We cannot reach any of the nodes that precede node (p)
- ii) If a list is traversed, the external pointer to the list must be persevered in order to reference the list again.
-
Answer :In linear list the next field of the last node contain a null pointer, when a next field in the last node contain a pointer back to the first node it is called circular list.Advantages – From any point in the list it is possible to reach at any other point
-
Answer :i) We can’t traverse the list backward.
ii) If a pointer to a node is given we cannot delete the node.
-
Answer :
It is a collection of data elements called nodes,
where each node is divided into three parts:
- An info field that contains the information stored in the node.
- Left field that contain pointer to node on left side.
- Right field that contain pointer to node on right side.
-
Answer :
- Compiler Design,
- Operating System,
- Database Management System,
- Statistical analysis package,
- Numerical Analysis,
- Graphics,
- Artificial Intelligence,
- Simulation.
Answer :
RDBMS – Array (i.e. Array of structures)
Network data model – Graph
Hierarchical data model – Trees
-
Answer :
The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type.
-
Answer :
Two. One queue is used for actual storing of data and another for storing priorities.
-
Answer :
Stack. Because of its LIFO (Last In First Out) property it remembers its ‘caller’ so knows whom to return when the function has to return. Recursion makes use of system stack for storing the return addresses of the function calls.
Every recursive function has its equivalent iterative (non-recursive) function. Even when such equivalent iterative procedures are written, explicit stack is to be used.
-
Answer :Polish and Reverse Polish notations
-
Answer :Prefix Notation:^ – * +ABC – DE + FG
postfix Notation:AB + C * DE – – FG + ^
Question 27. Difference Between Calloc And Malloc ?
Answer :
malloc: allocate n bytes.
calloc: allocate m times n bytes initialized to 0.
-
Answer :Linked List is one of the fundamental data structures. It consists of a sequence of ? nodes, each containing arbitrary data fields and one or two (”links”) pointing to the next and/or previous nodes. A linked list is a self-referential datatype because it contains a pointer or link to another data of the same type. Linked lists permit insertion and removal of nodes at any point in the list in constant time, but do not allow random access.
-
Answer :Each entry in a linked list is called a node. Think of a node as an entry that has three sub entries. One sub entry contains the data, which may be one attribute or many attributes. Another points to the previous node, and the last points to the next node. When you enter a new item on a linked list, you allocate the new node and then set the pointers to previous and next nodes.
-
Answer :A Queue is a sequential organization of data. A queue is a first in first out type of data structure. An element is inserted at the last position and an element is always taken out from the first position.
-
Answer :The symbol “*” tells the computer that you are declaring a pointer. Actually it depends on context.
In a statement like int *ptr; the ‘*’ tells that you are declaring a pointer.
In a statement like int i = *ptr; it tells that you want to assign value pointed to by ptr to variable i.
The symbol “*” is also called as Indirection Operator/ Dereferencing Operator.
-
Answer :Yes, a pointer is a variable and can be used as an element of a structure and as an attribute of a class in some programming languages such as C++, but not Java. However, the contents of a pointer is a memory address of another location of memory, which is usually the memory address of another variable, element of a structure, or attribute of a class.
-
Answer :There are two main parts, variable identifier and data type and the third type is optional which is type qualifier like signed/unsigned.
-
Answer :NULL can be value for pointer type variables.
VOID is a type identifier which has not size.
NULL and void are not same. Example: void* ptr = NULL;
-
Answer :STACK follows LIFO. Thus the item that is first entered would be the last removed.
In array the items can be entered or removed in any order. Basically each member access is done using index. No strict order is to be followed here to remove a particular element.
Array may be multidiamensional or onediamensional but stack should be onediamensional. but both are linear data structure.
-
Answer :Create two pointers, each set to the start of the list. Update each as follows:
- while (pointer1)
- {pointer1 = pointer1->next;
- pointer2 = pointer2->next;
- if(pointer2)pointer2=pointer2->next;
- if (pointer1 == pointer2)
- {
- print (”circularn”);}}
- Question 36. Whether Linked List Is Linear Or Non-linear Data Structure?Answer :According to Access strategies Linked list is a linear one.
- According to Storage Linked List is a Non-linear one\
- Question 37. State The Difference Between Arrays And Linked Lists?
- Answer :
- Question 38. Define A Stack?
- Answer :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 to as top of the stack. Stacks are also referred as piles, push-down lists and last-in-first-out (LIFO) lists.
- Question 39. List Out The Basic Operations That Can Be Performed On A Stack ?
- Answer :The basic operations that can be performed on a stack are
- Push operation.
- Pop operation.
- Peek operation.
- Empty check.
- Fully occupied check.
- Question40. State The Different Ways Of Representing Expressions?
- Answer :The different ways of representing expressions are
- Infix Notation.
- Prefix Notation.
- Postfix Notation.
- Question 41. Define A Priority Queue?
- Answer :Priority queue is a collection of elements, each containing a key referred as the priority for that element. Elements can be inserted in any order (i.e., of alternating priority), but are arranged in order of their priority value in the queue. The elements are deleted from the queue in the order of their priority (i.e., the elements with the highest priority is deleted first). The elements with the same priority are given equal importance and processed accordingly.
- Question 42. State The Difference Between Queues And Linked Lists?Answer :The difference between queues and linked lists is that insertions and deletions may occur anywhere in the linked list, but in queues insertions can be made only in the rear end and deletions can be made only in the front end.
- Question 43. Define A Deque?
- Answer :Deque (Double-Ended Queue) is another form of a queue in which insertions and deletions are made at both the front and rear ends of the queue. There are two variations of a deque, namely, input restricted deque and output restricted deque. The input restricted deque allows insertion at one end (it can be either front or rear) only. The output restricted deque allows deletion at one end (it can be either front or rear) only.
- Question 44. Why You Need A Data Structure?
- Answer :A data structure helps you to understand the relationship of one data element with the other and organize it within the memory. Sometimes the organization might be simple and can be very clearly visioned.
- Eg; List of names of months in a year –Linear Data Structure, List of historical places in the world- Non-Linear Data Structure. A data structure helps you to analyze the data, store it and organize it in a logical and mathematical manner.
- Question 45. What Do You Mean By Shortest Path?
- Answer :A path having minimum weight between two vertices is known as shortest path, in which weight is always a positive number.\
- Question 46. What Are The Tasks Performed During Postorder Traversal?
- Answer :
- Traverse the left sub-tree.
- Traverse the right sub-tree.
- Process the root node.
- Question 47. What Are The Tasks Performed During Inorder Traversal?
- Answer :
- Traverse the left sub-tree.
- Process the root node.
- Traverse the right sub-tree.
- Question 48. What Are The Tasks Performed During Preorder Traversal?
- Answer :Process the root node.
- Traverse the left sub-tree.
- Traverse the right sub-tree.
- Question 49. What Are The Tasks Performed While Traversing A Binary Tree?Answer :
- Visiting a node.
- Traverse the left sub-tree.
- Traverse the right sub-tree.
- Question 50. What Are The Different Binary Tree Traversal Techniques?
- Answer :Preorder traversal.
- Inorder traversal.
- Postorder traversal.
- Levelorder traversal.
- Question 51. What Is Meant By Binary Tree Traversal?
- Answer :Traversing a binary tree means moving through all the nodes in the binary tree, visiting each node in the tree only once.
- Question 52. State The Properties Of A Binary Tree?
- Answer :The maximum number of nodes on level n of a binary tree is 2n-1, where n≥1.
- The maximum number of nodes in a binary tree of height n is 2n-1, where n≥1.
- For any non-empty tree, nl=nd+1 where nl is the number of leaf nodes and nd is the number of nodes of degree 2.
- Question 53. Define A Right-skewed Binary Tree?
- Answer :A right-skewed binary tree is a tree, which has only right child nodes.
- Question 54. Define A Complete Binary Tree?
- Answer :A complete binary tree is a tree in which every non-leaf node has exactly two children not necessarily to be on the same level.
- Question 55. Define A Full Binary Tree ?
- Answer :A full binary tree is a tree in which all the leaves are on the same level and every non-leaf node has exactly two children.
- Question 56. Define Non-terminal Nodes In A Tree?
- Answer :All intermediate nodes that traverse the given tree from its root node to the terminal nodes are referred as non-terminal nodes.
- Question 57. Define Terminal Nodes In A Tree?
- Answer :A node that has no children is called a terminal node. It is also referred to as leaf node.
- Question 58. Define A Path In A Tree?
- Answer :A path in a tree is a sequence of distinct nodes in which successive nodes are connected by edges in the tree.
- Question 59. Define A Binary Tree?
- Answer :A binary tree is a finite set of nodes which is either empty or consists of a root and two disjoint binary trees called the left sub-tree and right sub-tree.
- Question 60. Define Forest?
- Answer :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.
- Question 61. What Do You Mean By Level Of The Tree?
- Answer :The root node is always considered at level zero, then its adjacent children are supposed to be at level 1 and so on.
- Here, node A is at level 0, nodes B and C are at level 1 and nodes D and E are at level 2.
- Question62. Define Depth And Height Of A Tree?
- Answer :The depth of the tree is the depth of the deepest leaf. The height of the tree is equal to the height of the root. Always depth of the tree is equal to height of the tree.
- Question 63. Define Depth And Height Of A Node?
- Answer :For any node ni, the depth of ni is the length of the unique path from the root to ni. The height of ni is the length of the longest path from ni to a leaf.
- Question 64. Define Parent Node?
- Answer :The node which is having further sub-branches is called the parent node of those sub-branches.
- Here C is the parent node of D and E.
कोई टिप्पणी नहीं:
एक टिप्पणी भेजें