Skip to main content

Posts

Showing posts from September, 2017
Tree and Graph Tree and graph can be classified under the non linear data structure. Here I have shared few algorithms of tree and graph. Graph algorithms Algorithm for DFS(Depth First Search) graph traversal: Step 1:Define a Stack of size total number of vertices in the graph. Step 2:Select any vertex as starting point for traversal.Visit that vertex and push it on to the Stack. Step 3:Visit any one of the adjacent vertex of the vertex which is at top of the stack which is not visited and push it on to the stack. Step 5:When there is no new vertex to be visit then use back tracking and pop one vertex from the stack. Step 6:Repeat steps 3, 4 and 5 until stack becomes Empty. Step 7:When stack becomes Empty, then produce final spanning tree by removing unused edges from the graph. Algorithm for BFS(Breadth First Search) graph traversal: Step 1:Define a Queue of size total number of vertices in the graph. Step 2:Select any vertex as starting point for traversal.Visit ...
Linear Data Structure Algorithm: Part II Linked List is another variation of Linear Data Structure. Though it is categorized in Linear Data Structure, it is not contiguous in nature. Rather it stores nodes in different locations at memory and links the nodes to each other forming a list, Therefore derives the name Linked List. Single Linked List Algorithm to create a node in Single Linked List: Allocate memory for ptr (pointer to new node) If ptr = NULL     print: Overflow: Memory not allocated End If     Read Data to be inserted in node Set nptr->info = data Set nptr->next = NULL     return nptr End Algorithm to Count Node in Linked List: Set count to 0 Set temp to First While temp != NULL     Set count = count + 1     Set temp = temp->next End While return count End Algorithm to Reverse a given Linked List: reverse(First)    Set temp = First  ...
Searching Sorting Algorithm for Linear Search: Step 1:Read the search element from the user Step 2:Compare, the search element with the first element in the list. Step 3:If both are matching, then Print:Given element found!!! and terminate the function Step 4:If both are not matching, then compare search element with the next element in the list. Step 5:Repeat steps 3 and 4 until the search element is compared with the last element in the list. Step 6:If the last element in the list is also doesn match, then Print:Element not found!!! and terminate the function. Algorithm for Binary Search: Step 1:Read the search element from the user Step 2:Find the middle element in the sorted list Step 3:Compare, the search element with the middle element in the sorted list. Step 4:If both are matching, then     Print:Given element found!!! and terminate the function Step 5:If both are not matching, then check whether the search element is smaller or larger tha...
Linear Data Structure Algorithm - Part I Hello all you young hearts! "You are never given a wish without also being given a power to make it come true. You may have to work for it however." -Richard David Bach Here is my blog that gives you information about various algorithm of Data Structure. In this blog I have shared information about Linear Data Structure. Linear Data Structure includes Stack, Queue and Linked List. This blog basically focuses on Stack and Queue. Stack Algorithms Algorithm for Push operation: If(top>size-1)     Print Stack is full Else     Top=top+1     a[top]=item     Print a[top] is added End If  Algorithm for Pop operation: If(top is less than 0)     Print Stack is empty Else     a[top]=item     Top=top-1     Print a[top] is deleted End If Algorithm for Peek operation If(top is less than 0)  ...
Hello All you beautiful people! Hope you’re doing fine… Installation of Android Studio…This is something which many of the beginners in this field are quite not so comfortable with…But that’s not so tough…It just requires proper internet connection and LOTS OF PATIENCE…Yes, while working with android an essential skill that you need to possess is PATIENCE… So, are you ready?? Let’s do it! First of all you need to download the setup file(.exe/android studio bundle) from any of your favorite browser as shown below…follow the link given below… https://developer.android.com/studio/index.html Click on the button that shows ‘Download Android Studio’ Accept the ‘Terms and Conditions’ and click on ‘Download’ Launch the .exe file that you have downloaded… And follow the setup wizard as given below… Click ‘Next’ Let the default checkbox be checked and click ‘Next’… Click on ‘I Agree’… Click ‘OK’… “What goes around comes around”: Make sure Android SDK and...