Total Pageviews

Wednesday 28 June 2023

Data Structures -1

 Data Structures 

Introduction to Data Structures 

Short Answers

1. Define Data Structures

            Data Structures is defined as the way of organizing all data items that consider not only the elements stored but also stores the relationship between the elements.

2. Define primary data structures

            Primary data structures are the basic data structures that directly operate upon the machine instructions. All the basic constants (integers, floating-point numbers, character constants, string constants) and pointers are considered as primary data structures.

3. Define static data structures

            A data structure formed when the number of data items are known in advance is referred as static data structure or fixed size data structure.

4. List some of the static data structures in C

Some of the static data structures in C are arrays, pointers, structures etc.

5. Define dynamic data structures

A data structure formed when the number of data items are not known in advance is known as dynamic data structure or variable size data structure.

6. List some of the dynamic data structures in C

Some of the dynamic data structures in C are linked lists, stacks, queues, trees etc.

7.Why you need a data structure?

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.

8. Difference between Abstract Data Type, Data Type and Data Structure

• An Abstract data type is the specification of the data type which specifies the logical and mathematical model of the data type.

• A data type is the implementation of an abstract data type.

• Data structure refers to the collection of computer variables that are connected in some specific manner. i.e) Data type has its root in the abstract data type and a data structure comprises a set
of computer variables of same or different data types

9. Define data type and what are the types of data type?

Data type refers to the kinds of data that variables may hold in the programming language. Eg) int, float, char, double – C

The following are the types of data type:

• Built in data type- int, float, char, double which are defined by programming language itself
• User defined data type- Using the set of built in data types user can define their own data type
Eg)

typedef struct student

{

int roll;

char name;

} S;

S s1 ;

Where S is a tag for user defined data type which defines the structure student and s1 is a variable of data type S.

10. Define an Abstract Data Type (ADT)

An abstract data type is a set of operations. ADTs are mathematical abstractions; nowhere in an ADT’s definition is there any mention of how the set of operations is implemented. Objects such as lists, sets and graphs, along with their operations can be viewed as abstract data types.

11. What are the advantages of modularity?

• It is much easier to debug small routines than large routines

• 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

12. State the difference between primitive and non-primitive data types

Primitive data types are the fundamental data types. Eg) int, float, double, charNon-primitive data types are user defined data types. Eg) Structure, Union and enumerated data types

13. State the difference between persistent and ephemeral data structure

Persistent data structures are the data structures which retain their previous state and modifications can be done by performing certain operations on it. Eg) Stack Ephemeral data structures are the data structures which cannot retain its previous state. Eg) Queues

14. What are the objectives of studying data structures?

• To identify and create useful mathematical entities and operations to determine what classes of problems can be solved using these entities and operations
• To determine the representation of these abstract entities and to implement the abstract operations on these concrete representation

15. Define linear data structures

            Linear data structures are data structures having a linear relationship between its adjacent elements. Example Linked lists

16. Define non-linear data structures

            Non-linear data structures are data structures that don’t have a linear relationship between its adjacent elements but have a hierarchical relationship between the elements. Example Trees and Graphs
17. Define Linked Lists

            Linked list consists of a series of structures, which are not necessarily adjacent in memory. Each structure contains the element and a pointer to a structure containing its successor. We call this the Pointer. The last cell’s pointer points to NULL.

18. State the different types of linked lists

The different types of linked list include singly linked list, doubly linked list and circular linked list.

19. List the basic operations carried out in a linked list
The basic operations carried out in a linked list include:
            1.Creation of a list
            2.Insertion of a node
            3.Deletion of a node
            4.Modification of a node
            5.Traversal of the list
20. List out the advantages of using a linked list

Ø  It is not necessary to specify the number of elements in a linked list during its declaration

Ø   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

 

21. List out the disadvantages of using a linked list

Ø  Searching a particular element in a list is difficult and time consuming

Ø   A linked list will use more storage space than an array to store the same number of elements

22. List out the applications of a linked list
            Some of the important applications of linked lists are manipulation of polynomials, sparse matrices, stacks and queues.

23. State the difference between arrays and linked lists

Arrays

Linked Lists

Size of an array is fixed

Size of a list is variable

It is necessary to specify the number of elements during declaration

It is not necessary to specify the number of elements during declaration

Insertions and deletions are somewhat difficult

Insertions and deletions are carried out easily

It occupies less memory than a linked list for the same number of elements

It occupies more memory



No comments:

Post a Comment