The document discusses different types of data structures including primitive, non-primitive, static, and dynamic data structures. It covers common linear data structures like arrays, linked lists, stacks, and queues as well as non-linear graphs. Operations like searching, sorting, insertion, updating and deletion are also described along with advantages of using data structures.
The document discusses different types of data structures including primitive, non-primitive, static, and dynamic data structures. It covers common linear data structures like arrays, linked lists, stacks, and queues as well as non-linear graphs. Operations like searching, sorting, insertion, updating and deletion are also described along with advantages of using data structures.
The document discusses different types of data structures including primitive, non-primitive, static, and dynamic data structures. It covers common linear data structures like arrays, linked lists, stacks, and queues as well as non-linear graphs. Operations like searching, sorting, insertion, updating and deletion are also described along with advantages of using data structures.
The document discusses different types of data structures including primitive, non-primitive, static, and dynamic data structures. It covers common linear data structures like arrays, linked lists, stacks, and queues as well as non-linear graphs. Operations like searching, sorting, insertion, updating and deletion are also described along with advantages of using data structures.
Data Structure is a way to store and organize data
so that it can be used efficiently.The data structure name indicates itself that organizing the data in memory. The data structure is not any programming language like C, C++, java, etc. It is a set of algorithms that we can use in any programming language to structure the data in the memory. To structure the data in memory, 'n' number of algorithms were proposed, and all these algorithms are known as Abstract data types. These abstract data types are the set of rules. Classification of Data Structure: Primitive Data structure The primitive data structures are primitive data types. The int, char, float, double, and pointer are the primitive data structures that can hold a single value. Non-Primitive Data structure The non-primitive data structure is divided into two types: Linear data structure Non-linear data structure Data structures can also be classified as: Static data structure: It is a type of data structure where the size is allocated at the compile time. Therefore, the maximum size is fixed.
Dynamic data structure: It is a type of
data structure where the size is allocated at the run time. Therefore, the maximum size is flexible. Major Operations
The major or the common operations that can
be performed on the data structures are: Searching: We can search for any element in a data structure. Sorting: We can sort the elements of a data structure either in an ascending or descending order. Insertion: We can also insert the new element in a data structure. Updation: We can also update the element, i.e., we can replace the element with another element. Deletion: We can also perform the delete operation to remove the element from the data structure. Advantages of Data structures The following are the advantages of a data structure: Efficiency: If the choice of a data structure for implementing a particular ADT is proper, it makes the program very efficient in terms of time and space. Reusability: The data structure provides reusability means that multiple client programs can use the data structure. Abstraction: The data structure specified by an ADT also provides the level of abstraction. The client cannot see the internal working of the data structure, so it does not have to worry about the implementation part. The client can only see the interface. Some of the very basic data structures in java are as follows: Arrays in Java This is the most simple data structure you will ever come across. It is a linear data structure. This data structure can refer to a group of similar data types by a common name. This is essentially useful when we need to conserve variable names. That’s where we can use the same name for all the different variables of the same type. Types of Java Arrays Single dimensional Array Double Dimensional Array Multi-Dimensional Array Linked Lists in Java Linked lists are better than arrays because they do not require the length specified to them. This means that linked lists are dynamic. Their sizes vary according to the user. This also means that the insertion and deletion operations are simpler. Stacks are a very popular data structure in programming. A lot of programs follow the stack concept. To understand stacks, imagine a book. Now you have 10 books. You keep putting books one on top of another. The result you see in front of you is a stack of books. There are a few technical terms related to stacks that you need to know.
ØPushing– Pushing is the addition of data
items at the top of the stack. ØPopping– Popping is the process of deleting the topmost element in the stack ØPeeking– Peeking is the process of reading the topmost element in the stack. Queue in Java A Queue is defined as a linear data structure that is open at both ends and the operations are performed in First In First Out (FIFO) order. FIFO Principle of Queue: A Queue is like a line waiting to purchase tickets, where the first person in line is the first person served. (i.e. First come first serve).Position of the entry in a queue ready to be served, that is, the first entry that will be removed from the queue, is called the front of the queue(sometimes, head of the queue), similarly, the position of the last entry in the queue, that is, the one most recently added, is called the rear (or the tail) of the queue. Some popular terms related to a queue that you need to know are: Enqueue– This is the process of adding elements to the rear of a queue. Dequeue– This is the process of removing data items from the front of a queue. Applications of Queues in Java: Queues are useful in designing operating system scheduling algorithms such as FCFS(First Come First Serve). They help power reservation systems, service center helplines, and traffic flow. They are essential for implementing Graph algorithms. Graphs in Java Graphs are the non-linear data structures in Java which have : Vertices/Nodes – These are the endpoints of an edge Edges- These connect the Nodes amongst each other. All edges are connected to two Nodes. Hence we can represent them by a finite set of ordered pairs(u,v). Generally, V denotes the number of Vertices and N denotes the number of edges in the graph. Sets in Java A set is a similar collection as an array. It contains elements in a linear order. However, there is a catch. There can not be any repeating elements in a set. This interface is present in the java. util package and extends the collection interface in Java. SortedSet and NavigableSet implement the Set Interface. Thank You!