Home Author
Author

nikoo28

  • ArraysTheory

    SORTING and its types

    by nikoo28
    5 minutes read

    What is sorting? Sorting is an algorithm that arranges the elements of a list in a certain order (either ascending or descending, as per the requirement). The output is simply a permutation of the input data. Why sorting? Sorting is one of the most important categories of algorithms in computer science. Sometimes sorting significantly reduces the problem complexity. We can use sorting as a technique to reduce the search complexity. Great research went into this category of algorithms because of its importance. These algorithms are very much used in many…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Misc

    Write a program to calculate pow(x,n)

    by nikoo28
    1 minutes read

    We will discuss how to calculate the result when a number ‘x’ is raised to the power ‘y’. Originally C provides a standard function that allows us to directly use the power function. It can be used in the following manner. Now suppose that we need to write a custom function by ourselves. Here are the sample methods by which we can do so. Simple Iterative method Recursive Method But in both these methods, the time complexity is of O(n), and this can take a long time in operation. We…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    What is a priority queue?

    by nikoo28
    2 minutes read

    In some situations we might need to find the minimum/maximum element among a collection of elements. Priority Queue ADT is the one which supports these kind of operations. A priority queue ADT is a data structure that supports the operations Insert and DeleteMin (which returns and removes the minimum element) or DeleteMax (which returns and removes the maximum element). These operations are equivalent to EnQueue and DeQueue operations of a queue. The difference is that, in priority queues, the order in which the elements enter the queue may not be…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    How do pointers to pointers work in C?

    by nikoo28
    2 minutes read

    We generally see cases like:-Here ptr is a pointer to a memory location of the variable x. What if we do something likeWhat we did just now was made a pointer to a pointer. Now the question arises, what happens behind the scene? Let’s assume an 8 bit computer with 8 bit addresses (and thus only 256 bytes of memory). This is part of that memory (the numbers at the top are the addresses): What we can see here, is that at address 63 the string “hello” starts. So in…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Here what we are trying to learn is the difference between:- and The difference is that const char * is a pointer to a const char, while char * const is a constant pointer to a char. const char * :- In this, the value being pointed to can’t be changed but the pointer can be. charĀ  * const :- In this, the value being pointed at can change but the pointer can’t. The third type is which is a constant pointer to a constant char (so nothing about it…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Misc

    How will you reverse a queue?

    by nikoo28
    1 minutes read

    Question: Give an algorithm to reverse a queue. You can only use generic functions of the Queue ADT. Input: 4, 8, 15, 16, 23, 42 Output: 42,23,16,15,8,4 To solve this question will take the help of an auxiliary stack. The steps involved will be:- Create an auxiliary stack S. Until the queue Q is not empty, push the elements of the queue, in the stack S. Now we have a stack in which the last element of the Queue is at the TOP. Until the stack is empty POP(S) and…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Misc

    Implementing a Queue

    by nikoo28
    2 minutes read

    Before implementing a queue, we must know the basic operations that should be available for a queue. Main Queue Operations:- enQueue(int data) :- Inserts an element at the end of the queue. int deQueue():- Removes and returns the element at the front of the queue. Auxiliary Queue Operations:- int front():- Returns the first element at the queue, without removing it. int queueSize():- Returns the size of the queue. int isEmptyQueue():- Indicates whether no elements are present. We can implement a queue using an ADT (Abstract Data Type). To implement a…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    What is a Queue?

    by nikoo28
    3 minutes read

    A queue is a linear data structure that stores data (similar to Linked Lists and Stacks). In a queue, the order in which the data arrives is important. Definition: A queue is an ordered list in which insertions are done at one end (rear) and deletions are done at other end (front). The first element that you insert, is the first one that is removed. This makes it a First In First Out (FIFO) or Last In Last Out (LILO) list. Basic Operations: The basic operations on this data structure…

    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