Skip to main content

Data Structures

Question: What is Data Structure ?

"Data structure" ek programming aur computer science concept hai jo data ko organize aur store karne ka tarika hai taaki usse efficently access aur manipulate kiya ja sake. Data structure ek particular way mein data ko arrange karta hai jisse data ko retrieve aur update karna aasani se ho. Yeh data ko organize karne ke liye various data types aur operations ka use karta hai.

Data structures ka use algorithms ko optimize karne mein hota hai, jisse ki data ko efficiently process kiya ja sake aur space aur time complexity ko minimize kiya ja sake. Yeh programming languages mein data ko store aur access karne ke tarike ko define karte hain.


Question: Give me explanation of Data Structures Type.


Types Of Data Structures:



1) Linear Data Structure

2) Non-Linear Data Structure



1) Linear data Structure: Linear data structure ek aise data structure hai jisme data elements linearly, yaani sequence mein store kiye jaate hain, ek ke baad ek. Yani, har element ke do neighbors hote hain except for the first and the last element. Linear data structures mein data ko linearly access kiya ja sakta hai.

Linear Data structures ke kuch important concepts hote hain:

  1. Arrays: Ye ek linear data structure hai jisme data elements ek saath stored hote hain. Har element ka ek unique index hota hai jisse use access kiya ja sakta hai.

  2. Linked Lists: Linked lists ek linear data structure hote hain jisme har node next node ka address store karta hai. Linked lists mein kisi bhi node ko access karne ke liye poora list traverse kiya jata hai.

  3. Stacks: Stacks ek linear data structure hote hain jisme data ko Last In First Out (LIFO) order mein store kiya jata hai. Data ko stack mein push (insert) aur pop (remove) kiya jata hai.

  4. Queues: Queues ek linear data structure hote hain jisme data ko First In First Out (FIFO) order mein store kiya jata hai. Data ko queue mein enqueue (insert) aur dequeue (remove) kiya jata hai.

  5. Trees: Trees ek non-linear data structure hote hain jisme data ko hierarchically organize kiya jata hai. Har node ek parent node ke saath connected hota hai aur multiple child nodes ho sakte hain.

  6. Graphs: Graphs ek non-linear data structure hote hain jisme vertices aur edges ke set se data ko represent kiya jata hai. Graphs ke through connections aur relationships ko model kiya jata hai.




 1)Array

2) LinkedList you can learn more about LinkedList by clicking on Link

3) Stacks

Comments

Popular posts from this blog

Block vs Inline Elements In HTML

  Block: Block element always start in New Line  Block element always start in new line occupy complete width available  Example: h2, p, div Inline Element: They do not start in new line occuply width as much required  Example: img, anchor a,span There are no different between div and span, only difference is div is block element and span is Inline, it will help you to group your content or elements

Time Complexity

What is time complexity ? Ans: Time complexity not a run time of a code, its totally depends on system configuration, processor, server , input size will increase time complexity. Time complexity ko likhne ke tarike jo hote hai use notation kehte hai. Notation is basically symbol NOTATION OF COMPLEXITY Best Case: kam se kam time me chla gya code best case hota hai Ω (Omega) Ω(1) se likhte hai Average Case: Ek average time jisme code chle  Θ(n+1)/2 Worst Case: Worst case ka mtlb kuch bhi ho jaye is time ko ye exceed nhi kregea O(n) Nested Loop me Time Complexity multiply hoti hai aur n^2 banti hai Wahi Do different loops me N+M hoti hai jisme jiski sabse bdi value hai wo big of O me jati hai O(1) - Constant Time: Operations that take a constant amount of time, regardless of the size of the input data. O(log n) - Logarithmic Time: Algorithms that have a logarithmic time complexity, often seen in binary search or certain tree-based algorithms. This is best time Complexity this i...

Find Unique Number in Array Java , XOR

 Question:  WAP to find unique number in Array Java package aRray ; import java . util .*; public class practicalArray { public static void main ( String [] args ) { Scanner scan = new Scanner ( System . in ) ; // Step 1: Input size of the array from the user int size = scan . nextInt () ; // Step 2: Create an integer array of the specified size int [] arr = new int [ size ] ; // Step 3: Initialize 'res' with the first element of the array int res = arr [ 0 ] ; // Step 4: Loop to read array elements and find the unique number for ( int i = 1 ; i < size ; i ++ ) { // Read an integer from the user and store it in the array arr [ i ] = scan . nextInt () ; // Step 5: Use XOR (^) operation to find the unique number res = res ^ arr [ i ] ; } // Step 6: Print the unique number System . out . print...