InterviewSolution
| 1. |
What are data structures? What are their types and sub-types? Explain each of the subtypes with examples. |
|
Answer» The data structures are named group of data of some data types. The data structures can be classified into following two types: 1. Simple Data Structure: These data structure are normally built from primitive data types like integers, reals, characters, boolean. Simple data structure can be classified into following two categories: (a) Array: Arrays refer to a named list of a finite number n of similar data elements. For example, int ARR[10]; Above array ARR have 10 elements, each elements will be referenced as Arr[0], ARR[1]………….ARR[9]. (b) Structure: Structure refers to a named collection of variables of different data types. For example, a structure named as STUD contais (Rno, Name, Mark), then individual fields will be referenced as STUD.fieldname such as, STUD.Rno, STUD.Name etc. 2. Compound Data Structure: Simple data structure can be combine in various waus to form more complex structures called compound data structures which are classified into following two categories: (a) Linear data structure: These data structures are a single level data structures representing linear relationship among data. Following are the types of linear data structure: (i) Stacks: Stack is a LIFO (Last In First Out) list. For example, stack of plates on counter, as that plates are inserted or removed only from the top of the stack. (ii) Queue: Queue is a FIFO (First In First Out) list. For example, line of people waiting for their turn to vote. (iii) Linked List: Linked lists are special lists of some data elements liked to one another. For example, peoples seating in a cinema hall where each seat is connected to other seat. (b) Non-Linear data structure: These data structures are multilevel data structure representing hierarchical relationship among data. For example, relationship of child, parent and grandparent. |
|