data structures
By: Anonymous3/28/2023105 views Public Note
1. What are Data Structures?
Data Structure is a branch of Computer Science. The study of data structure allows us to understand the organization of data and the management of the data flow in order to increase the efficiency of any process or program.
2. Why Create Data Structures?
Data structures serve a number of important functions in a program. They ensure that each line of code performs its function correctly and efficiently, they help the programmer identify and fix problems with his/her code.
3. What are some applications of Data structures?
Databases
Operating systems
Web search engines
Computer graphics
Compilers
Computer networks
Machine learning
Computer simulations
Video games
Financial systems
REAL TIME EX: cafe billing
4. Explain the process behind storing a variable in memory.
*A variable is stored in memory based on the amount of memory that is needed.
*The required amount of memory is assigned first.
*Then, it is stored based on the data structure being used.
5. Can you explain the difference between file structure and storage structure?
*FILE STRUCTURE: Representation of data into secondary or auxiliary memory say any device such as hard disk or pen drives that stores data which remains intact until manually deleted is known as a file structure representation.
*STORAGE STRUCTURE: In this type, data is stored in the main memory i.e RAM, and is deleted once the function that uses this data gets completely executed.
*The difference is that storage structure has data stored in the memory of the computer system, whereas file structure has the data stored in the auxiliary memory.
6. Describe the types of Data Structures?
LINEAR DATA STRUCTURE: A data structure that includes data elements arranged sequentially or linearly, where each element is connected to its previous and next nearest elements, is referred to as a linear data structure. Arrays and linked lists are two examples of linear data structures.
NON-LINEAR DATA STRUCTURE: Non-linear data structures are data structures in which data elements are not arranged linearly or sequentially. We cannot walk through all elements in one pass in a non-linear data structure, as in a linear data structure. Trees and graphs are two examples of non-linear data structures.
7. What is a stack data structure? What are the applications of stack?
*A Stack is a widely used linear data structure in modern computers in which insertions and deletions of an element can occur only at one end, i.e., top of the Stack. It is used in all those applications in which data must be stored and retrieved in the last.
*Stack follows a particular order in which the operations are performed. The order may be LIFO(Last In First Out) or FILO(First In Last Out).
APPLICATIONS
=Reverse a Data
=Backtracking
=Memory Management
=Undo/Redo operations
=Browser history
=REAL TIME EX
=book arrangement
8. What are different operations available in stack data structure?
=push
=pop
=top
=is Empty
=size
9. What is a queue data structure? What are the applications of queue?
*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 the item that goes in first is the item that comes out first.
*It is similar to the ticket queue outside a cinema hall, where the first person entering the queue is the first person who gets the ticket.
APPLICATIONS
=Task Scheduling
=Message Buffering
=Event Handling
=Traffic Management
REAL LIFE EX:queue at any place
10. What are different operations available in queue data structure?
=enqueue
=dequeue
=rear
=front
=isEmpty
=size
11. Differentiate between stack and queue data structure.
Stack/Queue
*Stack is a linear data structure where data is added and removed from the top.==Queue is a linear data structure where data is ended at the rear end and removed from the front.
*Stack is based on LIFO(Last In First Out) principle ==Queue is based on FIFO(First In First Out) principle
*Insertion operation in Stack is known as push==Insertion operation in Queue is known as eneque.
*Delete operation in Stack is known as pop==Delete operation in Queue is known as dequeue.
*Only one pointer is available for both addition and deletion: top()==Two pointers are available for addition and deletion: front() and rear()
*Used in solving recursion problems==Used in solving sequential processing problems
12. How to implement a queue using stack?
we can implement queue using stack by using 2 stacks
13. How do you implement stack using queues?
A stack can be implemented using two queues. We know that a queue supports enqueue and dequeue operations. Using these operations, we need to develop push, pop operations.
14. What is array data structure? What are the applications of arrays?
An array is a linear data structure that collects elements of the same data type and stores them in contiguous and adjacent memory locations.