What is data structures and algorithms, data structures tutorial, data structures types data structures interview questions, data structures in c, data structures in python, data structures in java, data structures and algorithms in java pdf.
What is Data Structures?
Data Structures is a representation of logical relationships existing between individual elements of data. In other words, Data Structures define a way of organizing all data items that consider not only the elements stored but also their relationship to each other. The term Data Structures is used to describe the way data is stored.
To develop a program of an algorithm we should select appropriate Data Structures for that
algorithm. Therefore, Data Structures is represented as Algorithm + Data Structures = program.
Data Structures is said to be linear if their elements form a sequence or a linear list. The linear data
structures like an array, stacks, queues, and linked lists organize data in linear order. A data
structure is said to be non-linear if its elements form a hierarchical classification where data items
appear at various levels.
Trees and Graphs are widely used in non-linear Data Structures. Tree and graph structures represent
a hierarchical relationship between individual data elements. Graphs are nothing but trees with certain
Data Structures Tutorial
Data structures are the building blocks of a program. A program may not work as expected So as a programmer it is mandatory to choose the most appropriate data built using improper data structures for a program.
The term data means a value or set of values. It specifies either the value of a variable or a constant (e.g., marks of students, name of an employee, address of a customer, the value of pi, etc.). While a data item that does not have subordinate data items is categorized as an elementary item, the one that is composed of one or more subordinate data items is called a group item. For example, a student’s name may be divided into three sub-items-first names, middle name, and last name, but his roll number would normally be treated as a single item.
A record is a collection of data items. For example, the name, address, course, and marks obtained are individual data items. But all these data items can be grouped together to form a record.
A file is a collection of related records. For example, if there are 60 students in a class, then there are 60 records of the students. All these related records are stored in a file. Similarly, we can have a file of all the employees working in an organization, a file of all the customers of a company, a file of all the suppliers, so on and so forth.
Moreover, each record in a file may consist of multiple data items but the value of a certain Moreover, the data item uniquely identifies the record in the file. Such a data item K is called a primary key, and the values K, K, … in such a field are called keys or key values. For example, in a student’s record that contains roll number, name, address, course, and marks obtained, the field roll number is a primary key. The rest of the fields (name, address, course, and marks) cannot serve as primary keys, since two or more students may have the same name, or may have the same address (as they might be staying at the same place), or may be enrolled in the same course, or have obtained same marks.
Types of Data Structures
• Primitive Data Structures.
• Non-primitive Data Structures.
Primitive Data Structures are the basic Data Structures that directly operate upon the machine
instructions. They have different representations on different computers.
Examples of Primitive Data Structures: Integers, floating-point numbers, character constants, string constants, and pointers come under this category.
Non-primitive Data Structures are more complicated Data Structures and are derived from primitive
Data Structures. They emphasize grouping the same or different data items with the relationship between
each data item.
Examples of Non- Primitive Data Structures: Arrays, lists, and files come under this category.
Non-Primitive Data Structures can further be classified into two categories:
- Non-linear Data Structures
Linear: If the elements of a data structure are stored in a linear or sequential order, then it is a linear data structure.
Examples of Linear Data Structures: Arrays, linked lists, stacks and queues.
Representation of Linear Data Structures: Linear data structures can be represented in memory in two different ways. One way is to have a linear relationship between elements by means of sequential memory locations. The other way is to have a linear relationship between elements by means of links.
Non-Linear Data Structures: If the elements of a data structure are not stored in sequential order, then it is a non-linear data structure. The relationship of adjacency is not maintained between elements or non-linear data structure.
Examples of Non-Linear Data Structures: Trees and Graphs.
Data Structures Operations:
1. Traversing– It is used to access each data item exactly once so that it can be processed.
2. Searching– It is used to find out the location of the data item if it exists in the given collection of
3. Inserting– It is used to add a new data item in the given collection of data items.
4. Deleting– It is used to delete an existing data item from the given collection of data items.
5. Sorting– It is used to arrange the data items in some order i.e. in ascending or descending order in
case of numerical data and in dictionary order in case of alphanumeric data.
6. Merging– It is used to combine the data items of two sorted files into a single file in the sorted