Home Theory
Category:

Theory

View theory topics

  • Question: Given an integer N, find the prime numbers in that range from 1 to N. Input: N = 25Output: 2, 3, 5, 7, 11, 13, 17, 19, 23 We have several ways of finding prime numbers. Some of the methods are discussed in the these posts. Method 1 Method 2 Method 3 In this post we will find the first N prime numbers using the Sieve of Eratosthenes. This technique is helpful in scenarios when we have to give immediate results and we need to query the prime numbers …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Here we will discuss the easiest and most simple way to change case of alphabets. Hint : We will be using bit hacks. Often during our programming needs we need to change the case of alphabets. This can be a problem requirement or simply our need to solve the question. There are several ways to do it, but what can be more beautiful than using bit hacks for the same. We discusses some of the BIT Hacks in these posts:- Low Level Bit Hacks Some advanced Bit Hacks Here I …

    0 FacebookTwitterLinkedinWhatsappEmail
  • MiscTheory

    Advanced level Bit Hacks

    by nikoo28
    10 minutes read

    Here we shall discuss some high level Bit hacks that if used cleverly can really speed up your program execution time. We discussed some of the basic hacks in this post:- Low level bit hacks you must know. Please go through the post to get a little understanding of how the things work. Smart learners are anyways welcome to proceed. ;-) BIT HACK 6: Turn off the rightmost 1-bit. Now it finally gets more interesting!!! Bit hacks #1 – #5 were kind of boring to be honest. This bit hack …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Low level Bit Hacks that you must know

    by nikoo28
    8 minutes read

    Here we shall discuss some very low level Bit hacks that can really speed up your program execution time when used effectively. Every now and then we see bit level operators. Bit hacks are ingenious little programming tricks that manipulate integers in a smart and efficient manner. Instead of performing some operation (such as counting the 1 bits in an integer) by looping over individual bits, these programming nuggets do the same with one or two carefully chosen bitwise operations. To get things going I’ll assume that you know what …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Playing with Pointers

    by nikoo28
    5 minutes read

    Question: What is a Pointer? What are its limitations? What are its benefits? How do we use it? What all operation we can perform using it? In this article we are going to discover answers to all these questions. Pointer is a variable that contain the address of another variable and that variable can be a structure, array or basic data type. The basic syntax to define the pointer is as follows: Datatype * identifier; Datatype is the data type of the variable whose address we are going to store …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Unlocking the Enumeration/enum Mystery

    by nikoo28
    3 minutes read

    What are enums actually? Enums provide an opportunity to the user to define a shorthand for fixed set of constants like months in a year, gender etc. Enumeration is the list of constant integer values, which means that the enum values can’t be modified. Here we are going to explain Enumeration usage rules and constraints in C language. In C Enums are defined by enum keyword. The enum definition is analogous to the way a structure is defined . Syntax: tagname – It is the name given to the enum …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Symbol Table Implementations

    by nikoo28
    2 minutes read

    Symbol Tables can be implemented in many ways and here are some of them. Unordered Array Implementation With this method, just maintaining an array is enough. It needs O(n) time for searching, insertion and deletion in the worst case. Ordered [Sorted] Array Implementation In this we maintain a sorted array of keys and values. Store in sorted order by key keys[i] = ith largest key values[i] = value associated with ith largest key Since the elements are sorted and stored in arrays, we can use simple binary search for finding …

    0 FacebookTwitterLinkedinWhatsappEmail
  • Theory

    Symbol Tables

    by nikoo28
    2 minutes read

    Since childhood, we have all used a dictionary, and many of us have used a word processor (say Microsoft WORD) which comes with a spell checker. The spell checker is also a dictionary but limited. There are many real time examples for dictionaries and few of them are:- Spelling checker The data dictionary found in database management applications Symbol tables generated by loaders, assemblers, and compilers Routing tables in networking companies (DNS Lookup) In computer science, we generally use the term symbol table rather than dictionary, when referring to the …

    0 FacebookTwitterLinkedinWhatsappEmail
  • TheoryTrees

    Level order Traversal in a Binary Tree

    by nikoo28
    5 minutes read

    We discussed the basic tree traversals in this post – Basic tree traversals We learned about the pre-order traversal, in-order traversal and post-order traversal. These are standard traversals that are related with root, left sub-tree and the right sub-tree. Level order traversal follows an entirely different approach and is not related with the left sub-tree and the right sub-tree. It does not hold the same property for all the nodes and hence recursive technique cannot be applied to level order traversal. Let us try to understand with the help of …

    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