Showing posts with label Data Structure. Show all posts
Showing posts with label Data Structure. Show all posts

Saturday, July 13, 2019

What is The Sequence of Learning Data Structures and Algorithms

In this post i will tell you one of the important thing how data structures and algorithms is learning process. Many students or Beginner will confuse where to start to learn Data Structure and algorithms. Here is the right place to know it. The following sequences of learning Data Structures and Algorithms for all.


  1. Arrays(Sorting, searching, adding , deleting, traversing)
  2. singly linked-list using Arrays
  3. doubly linked-list using Arrays
  4. circular linked-list using Arrays
  5. doubly circular linked-list using Arrays
  6. queue using arrays
  7. circular queue using arrays
  8. stack using arrays
  9. double stack using arrays
  10. Repeat all of the above using ‘struct’ in both ‘recursive’ and ‘non-recursive’ implementations.
  11. trees using structs
  12. Binary search tree
  13. AVL Trees
  14. RB Trees
  15. Graphs


Algorithms:


  • Searching algorithms
  • Sorting algorithms
  • Maximum and minimum element in a data structure
  • Sum and average of all elements in the data structures
  • Inorder, preorder and post-order tree traversals
  • BFS and DFS
  • Graph algorithms- Shortest path
  • Greedy algorithms
  • Divide and conquer
  • Backtracking
  • Dynamic programming  

Thursday, January 10, 2019

How to Begin to learn Data Structure?

In this post you will know how to learn DS and what are the best sources to learn fundamentals of DS. Learning programming and Data Structures are just like learning new skills, where you have to read, to practice, to do mistakes, and to gain experience. I personally don’t recommend a single source of information as every one will explain the concept in totally different way it’ll open your mind to so many questions and applications for that specific DS you learn.
Don’t also mind learning DS in multiple languages and on multiple frameworks since you are going to notice , for example, that the applications of DS in C are really different than those in Python, and the way you implement things there, are not the same way you implement them here.

Data Structures and Algorithms are the basic building blocks of a Computer Science graduate’s career.

For beginner’s level, the data structures you should be well aware of are:

Arrays. The simplest Data Structure and will help you solve 90% of the questions unless time complexity is a major constraint.

Linked List. Operations are faster than those in arrays.

Stacks.
Queues.
Binary Trees. Faster traversal.
Heap.
Hash map.
For algorithms, I will suggest you to cover cover all the areas and just not concentrate on your competiton related stuffs. Algorithms are essential for a good programmer and knowledge never goes to waste.

Sorting:
Bubble Sort
Selection Sort. While this two sorting algorithms are traditional and more time consuming, they are also easy to implement.
Quick Sort. If space complexity is a constraint.
Merge Sort. If space complexity isn't an issue.
Searching:

Linear Search. Easiest one but please don't go for it during competitive coding.
Binary Search. Go for this one instead.
Interpolation Search. Further improvement on Binary Search algorithm.


Spanning Trees:
Djikstra’s Algorithm.
Prim’s Algorithm.
Kruskal’s Algorithm.
Bellman Ford.
Floyd Warshall.
Travelling Salesman Problem.
Max Flow Min Cut.
Coming to how to practice, the best way to practice is to write on a piece of paper with pen. Understand the logic first. Geeks for Geeks and Tutorials Point are two very good websites for both DS and Algorithms. You may also practice from IndiaBix. It has MCQs which you can practice. Strengthens your base. You can find useful video lectures on YouTube as well. Learn the working mechanism. Try on pen and paper first. Then type it on a computer. In this way you will remember it better.

To start with I’d recommend Tutorials Point. Link:Data Structure and Algorithms (DSA) Tutorial. This will cover your basic concepts on Data Structures and Algortihms.

Once you are done with Tutorials Point, go to an Advanced level. Read Geeks for Geeks. Link:Data Structures - GeeksforGeeks . 
These two websites will help you get a very good understanding on the subject matter. You may also refer to the Coursera video lectures. The concept of Amortized Analysis is best explained there.

Monday, August 27, 2018

Best place to learn Data Structure and Algorithms Online

In this post you will know the best place to learn data structures and algorithms through online. Before learning algorithms/ds, learn a programming language first.  The following are the 3 best places to learn ds and algorithms. They are











Tuesday, November 22, 2016

Data Structre Interview Questions

In this article we will learn some frequently asked Data Structure Interview Questions for freshers and Experienced Persons. Earlier i have shared Introduction to Data Structure for for the sake of freshers. These Questions also useful who are attending Technical Written Test or Online Test. So, every Software Developer go through these questions and clear your exam or technical interview.

1) What is Data Structure?

Ans: A Data Structure is the way organizing the data elements in computer memory in a manner that is convenient. Here Data means a combination of numeric and non-numeric values. Structure means the way of representing the data in meaningful order. Data Structure are used to represent numeric and non-numeric in a meaningful order. Data Structure are not only the items stored,but also their relationship to each other.

2)   Difference Between  File structure and storage structure?

Ans: The main difference is the memory area that is being accessed. When dealing with the structure that resides the main memory of the computer system this is called as storage structure whereas a storage structure representation in auxiliary memory is called as file storage structure.

3)  What is difference between Arrays and Linked List?

Ans:  Both Arrays and linked list can be used to store similar data in memory. The main difference between Array and linked list is array can store element in contiguous memory locations whereas liked list store individual elements somewhere in memory.    Arrays are used when the number of elements to be stored is fixed. They are easy to traverse,search and sort. In the case of Linked lists are useful when the number of data items in the collection are likely to vary. In array each element is independent that means it doesn't contain connection with previous element. But in linked list the order of the elements is maintained by explicit links between them. 

4) In what areas Data Structures applied?

Ans: Data Structure is important in almost every aspect where data is involved. For example Operating System,database management,numerical analysis,compiler design,graphics and statistical analysis etc...

5) Difference between PUSH and POP?

Ans:  PUSH and POP applies to the way data is stored and retrieved in a stack. A push represents data being added to it that means data is being pushed into stack. on the other hand a pop represent data retrieval,and in particular refers to the topmost data being accessed.

For more details:  JAVA STACK tutorial

6)   What is the advantage of the heap over a stack?

Ans:  The heap is more flexible than a stack. Since,memory space for the heap can dynamically allocated and de-allocated as needed. However,memory of the heap can at times be slower when compared to the stack.

7)  How does selection sort work?
Ans: The selection sort works by picking the smallest number from the list and placing it at the front. This process is repeated for the second position towards end of the list. This is called simplest sort algorithm.



8)   How do you search for target key in a linked list?

Ans:  To find target key in linked list,you have to apply sequential search. Each node traversed and compared with the target key,and if it is different,then it follows the link to the next node. This traversal continues until either target key is found or if the last node is reached.

Recommended to Read: Linked list with example

9)  Which is the best sorting algorithm is considered the fastest?

Ans: There are many sorting algorithms, but my opinion quick sort,bubble sort,merge sort,radix sort etc.. But you should considered each algorithm is designed for a particular data structure and data set. So, it would depend on the data set that you would want to sort.

10) What is data abstraction?

Ans: It is a powerful tool for breaking down complex data problems into manageable chunks. It separates the specification of data type from its implementation. This is applied by initially specifying the data objects involved and the operations to be performed on these data objects without being overly concerned with how the data objects will be represented and stored in memory.

Saturday, January 30, 2016

Linked List in java

In this article we will discuss about linked list 
in data structure using java programming 
language.I had already posted Introduction
to Data Structure . while you develop computer
programming software projects you should 
include linked list data structure to organize 
your data in the computer memory.







Linked list is a common and simple data structure.This data structure comes under linear data structure which consists of group of nodes and  the elements are stored in the sequence order in the computer memory. A node contains two fields,they are Data item & Link address.Data Item contains actual value and link contains next node address. In this we use a special pointer called HEAD, contains first node address.



Difference between Array and Linked List:

Array:


  • Array is a collection of Homogeneous elements
  • we can easily identify a particular element in the list
  • It is a static Data structure
  • Here is size is fixed
Linked List:

  • Linked list is a linear data structure
  • It is not easy to identify a particular element in the list
  • It is a dynamic Data Structure
  • Here size is not fixed

Advantages of Linked List:

  1. we can easily implement stack,queue using linked list
  2. we can easily insert and delete elements in the list
  3. linked list has dynamic nature so memory size increase automatically. So we need to know the size in advance

Types of Linked Lists:

Lined Lists are three types. They are

1. Singly Linked List
2.Doubly Linked List
3.Circular Linked List

Singly Linked List:

It is a collections of linear data elements.In this an element is referred as a node. A node contains two fields,they are data item & link address. Data item contains actual value and link contains next node address.Int this we use a special pointer called HEAD,contains first node address.It means singly linked list first node address will be store in the Head pointer.Last node link contains the NULL pointer.

The representation of single Linked List is as follows:


we can develop the single linked list by using the following operations:

1.Creation
2.Traversing
3.Insertion
4.Deletion

1.Creation:

To create a linked list first we check the condition whether the head is null or not. If the head is null then create a new node and assign that address to the head. Otherwise create a new node and assign that address to the previous node link.

Algorithm:

Step 1: Start
Step 2: if(Head==NULL)
                p=new node
                p---->data=num
                p---->link=NULL
                head=p

Step 3: else
                t=new node
                t----->data=num
                t----->link=NULL
                p---->link=t
                p=t

Step 4: stop

2.Traversing:

In this we display each and every element in the list.In single linked list traversing can possible only one direction that is from head to last element.


Algorithm:

Step 1: Start
Step 2: Set a=head
Step 3: Repeat the steps 4,5 while(a!=NULL)
Step 4: print a----->data
Step 5: set a=a----->link
Step 6: stop


3. Insertion:

In single linked list we can insert the element in three ways: they are

1. Insert the element at the beginning of the list
2.Insert the element at the end of the list
3.Insert the element at after specified node


Insert the element at the beginning of the list:

If we want insert the element at the beginning of the list then we create new node and assign that new node address to the head and also establish to the next node.


Before Insertion:






After Insertion:



Algorithm: insert-beginning(num)

Step 1:  Start
Step 2: t=new node
step 3: t----->data=num
Step 4: t------>link=head
step 5: head=t
step 6: Stop


Insert the element at the end of the list:

To insert the element at the end of the list we can create a new node and assign that node address to previous node link and assign NULL Pointer.

Before Insertion:



After Insertion:




Algorithm:  Insert-ending(num)

Step 1: Start
Step 2: t=new node
step 3: t----->data=num
step 4: t----->link=NULL
step 5: p----->link=t
step 6: p=t
step 7: Stop


Insert the element at the after specified node:

To insert an element at the specified node first we check the whether the node is in the list or not. If the specified node is found then that node points to the new node element and the node element points to the next node.Otherwise display element is not found.


Before Insertion:



After Insertion:




Algorithm: Insert-after(ele,num)

Step 1: Start
Step 2: set a=head
Step 3: repeat the steps 4&5 while(a!=NULL)
Step 4: if(ele==a--->data)then
               t=new node
               t----->data=num
               t----->link=a----->link
               a----->link=t
Step 5: else
               a=a----->=t

Step 6: Stop


Deletion:

If we want to delete an element from the list we can follow two methods:

a. if the deleted element is first element,then assign second node address to the head.
b. if the deleted element is middle element,then assign next node address to the previous node.


Before Deletion:



After Deletion:



Algorithm: deletion(num)

Step 1: Start
Step 2: set a=head
Step 3: if(a---->data==num)then
              head=a----->link,delete a;
step 4: else
               set b=a,
               set a=a----->link

step 5: repeat the steps 6&7 while(a!=NULL)
Step 6: if(a---->data==num)then
                b---->link=a---->link
              delete a;
step 7:  else
                 set b=a
                 a=a----->link

Step 8: Stop





















High Paying Jobs after Learning Python

Everyone knows Python is one of the most demand Programming Language. It is a computer programming language to build web applications and sc...