Home Author
Author

nikoo28

  • Linked List

    Important operations on a Linked List

    by nikoo28
    6 minutes read

    We covered some of the basic operations on a Linked List in this post. Basic operations on a Linked List However, in order to create a functional Linked List, we need even more operations before we can proceed further. Some of these operations are:- Inserting a node in the beginning of the Linked List. Inserting a node in the middle of a List. Inserting at a certain position Inserting after a specific node. Deleting a node from the Linked List. Deleting the entire Linked List. Inserting a node in the …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Linked List

    Basic Operations on a Linked List

    by nikoo28
    5 minutes read

    Here are some of the basic operations on a singly Linked List. Creating a new List Adding new elements Traversing a List Printing a List Basic functions to perform the above techniques have been defined in the code below. Creating a new list A new Linked List creation means that we do not have any elements in the list and we want to start fresh. This means allocating space in the memory for a node and then inserting the data into it. Since only a single node is created, the …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    What is Backtracking?

    by nikoo28
    1 minutes read

    Backtracking is the method of exhaustive search using divide and conquer. Sometimes the best algorithm for a problem is to try all the possibilities. This is always slow, but there are standard tools that can be used for help. Tools: algorithms for generating basic objects, such as binary strings [2n possibilities for n-bit string], permutations [n!], combinations [n!/r!(n-r)!], general strings [k-ary strings of length  n has kn possibilities], etc… Backtracking speeds the exhaustive search by pruning. Example Algorithms of Backtracking Binary Strings: generating all binary strings Generating k-ary Strings. The …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Discuss the Tower Of Hanoi puzzle

    by nikoo28
    3 minutes read

    The tower of Hanoi is a mathematical puzzle. It consists of three rods, and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks on one rod in ascending order of size, the smallest at the top, thus making a conical shape. The objective of the puzzle is to move the entire stack to another rod, satisfying the following rules:- Only one disk can be moved at a time. Each move consists of taking the upper disk from one of the …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Recursion and Memory (Vizualization)

    by nikoo28
    1 minutes read

    Each recursive call makes a new copy of that method (more specifically speaking ‘the variables’) in memory. Once a method ends (i.e returns some data), the copy of that returning method is removed from the memory. The recursive solutions look simple but visualization and tracing takes time. For better understanding, let us see the following example. For this example. if we call the print function with n = 4, visually our memory assignment may look like this:- Now, let us consider our factorial function. The visualization of this will be:-

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    About Recusrion

    by nikoo28
    2 minutes read

    What is Recursion? Any function which calls itself is called a recursive function. A recursive method solves a problem by calling a copy of itself to work on a smaller problem. This is called the recursion step. The recursion step can result in many more such recursive calls. It is important to ensure that the recursion terminates. Each time the function calls itself with a slightly simpler version of the original problem. The sequence of smaller problems must eventually converge on the base case. Why Recursion? Recursion is a useful …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Master Theorem for Divide and Conquer

    by nikoo28
    2 minutes read

    All divide and conquer algorithms divides the problem into sub problems, each of which is part of the original problem, and then perform some additional work to compute the final answer. As an example, merge sort algorithm operates on two sub-problems, each of which is half the size of the original and performs O(n) additional work for merging. This gives the running time equation. T(n) = 2T(n/2) + O(n) The following theorem can be used to determine the running time of divide and conquer algorithms. For a given program (algorithm), …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Types of Analysis of Algorithms

    by nikoo28
    1 minutes read

    To analyze the given algorithm we need to know on what inputs the algorithm is taking less time (performing well) and on what inputs the algorithm is taking huge time. We know that an algorithm can be represented in form of an expression. That means we represent the algorithm with multiple expressions: one for case where it is taking less time and other for the case where it is taking more time. In general- Worst Case:- Defines the input for which the algorithm takes huge time. Input is the one …

    0 FacebookTwitterLinkedinWhatsappEmail

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More