Skip to main content

What is a Data Structure

 

Q) What is a Data Structure?

  • A data structure is a way of organizing the data so that the data can be used efficiently.
  • Different kinds of data structures are suitable to different kinds of applications.
  • Example- compiler usually use hash tables to look up identifiers.

Q) What is a linear and non-linear data structure?

  • Linear:
    • A data structure is said to be linear if its elements from a sequence or a linear list
    • Example- Array, Linked list.
  • Non-linear:
    • A data structure is said to be non-linear if the traversal of nodes is nonlinear in nature.
    • Example- Graphs and Trees.

Q) What is a Linked List and What are its types?

  • A linked list is a linear data staructure (like arrays) where each element is a separate object.
  • Each element (that is node) of a list is comprising of two items- the data and a reference to the next node.
  • Types of Linked List:
    • Singly Linked List:
      • Every node stores address or reference of next node in list and the last node has next address or reference as NULL.
      • Example 1->2->3->4->NULL. 

    • Doubly Linked List:
      • Two references associated with each node, One of the reference points to the next node and one to the previous node.
      • Example NULL<-1<->2<->3->NULL.
    • Circular Linked List:
      • All nodes are connected to form a cirle. There is no NULL at the end.
      • A circular linked list can be a singly circular linked list or doubly circular linked list.
      • Example 1->2->3->1[The next pointer of last node is pointing to the first]

Note:
    Hello Guys, Don't Stop Learning keep Going..............

Popular posts from this blog

Python Program to Convert Hectare to Acre

             Python Program to Convert Hectare to Acre       Generally 1 hectare = 2.471 acres. It is used find the area of the lands or farming. It is comes under unit conversions.       Input:          1      Out put:           2.471044            Explanation :                    Generally 1 hectare = 2.471044 acres                       Code:          hectare=int(input())           print(hectare*2.471044)           Note:     Hello Guys, Don't Stop Learning keep Going..............

Python Program to check given number is Prime Number or Not

     Python Program to check given number is Prime Number or Not       A number Greater than 1 which has only two factors. They are 1 and itself. In computer science prime number concept is very interesting and most important in cryptography.          Input:          7      Out put:          prime         Explanation :           Factors for 7 is 1 and itself then it is prime number.      Code:         x=int(input()) c=0 for i in range(2,x):      if(x%i==0):           c=1           break if(c==1):      print("not a prime") else:      print("prime") Note:     Hello Guys, Don't Stop Learning keep Going..............  

Python Program to Check whether a character is a Vowel or Consonant

                  Python Program to Check whether a character is a Vowel or Consonant   In this we are going to learn given character is vowel or Consonant. Generally there are 5 vowels they are a,e,i,o,u and remaining are the consonants in alphabets of 26. we can write this program by using strings. string is a collection of characters.         Input:        k      Out put:           Consonant                Explanation :             vowels={a,e,i,o,u,A,E,I,O,U}          if input character in the above list then vowels, else consonant                   Code:         r=input()       # input string         s="aeiou"    ...