Home Tags Posts tagged with "Trivia"
Tag:

Trivia

Some general stuff

  • MiscTheory

    Advanced level Bit Hacks

    by nikoo28
    7 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
    6 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

    Unlocking the Enumeration/enum Mystery

    by nikoo28
    2 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
  • MiscTheory

    Algorithm Analysis – Crash Course

    by nikoo28
    3 minutes read

    We have been discussing the time complexities of each of the algorithm that we have discussed. Let us try to analyze, how these time complexities are calculated. O(1) Time complexity of a function (or set of statements) is considered as O(1) if it doesn’t contain loop, recursion and call to any other non-constant time function. For example swap() function(which interchanges two numbers) has O(1) time complexity. A loop or recursion that runs a constant number of times is also considered as O(1). For example the following loop is O(1). O(n)…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Question: Given a sequence of integers, find the median of the integers? Input: arr [] = {15, 23, 4, 16, 8, 42}. Find median. Output: 15 Since the question does not specify anything we cannot assume that the given array is a sorted one. The definition of median is the (n/2)th element of a sorted sequence of integers. This definition makes our approach simpler. All we need to do is sort the integers and then return the (n/2)th element. Here is the code for above approach. I use quick sort…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Misc

    Some general tips for programming.

    by nikoo28
    5 minutes read

    A Programming Contest is a delightful playground for the exploration of intelligence of programmers. To start solving problems in contests, first of all, you have to fix your aim. Some contestants want to increase the number of problems solved by them and the other contestants want to solve less problems but with more efficiency. Choose any of the two categories and then start. If you are a beginner, first try to find the easier problems.Try to solve them within short time. At first, you may need more and more time…

    0 FacebookTwitterLinkedinWhatsappEmail
  • MiscTheory

    What is a wild pointer?

    by nikoo28
    1 minutes read

    Question: What is a wild pointer in a program? Uninitialized pointers are known as wild pointers. These are called so because they point to some arbitrary memory location and may cause a program to crash or behave badly. This can be understood from the below examples. Please note that if a pointer p points to a known variable then it’s not a wild pointer. In the below program, p is a wild pointer till this points to a. If we want pointer to a value (or set of values) without…

    0 FacebookTwitterLinkedinWhatsappEmail
  • MiscTheory

    What is a memory leak?

    by nikoo28
    1 minutes read

    Question:What is a memory leak in a program? We have been writing many programs where we have used the “free()” keyword. One such example can be found in the “Delete the complete list” function found in the post – Important traversals in a Linked List. The code snippet is:- This is done due to a reason. When we allocate a memory in a program, usually that memory is unallocated once the execution of the program finishes. However, there may be some cases where the program runs forever and these scenarios,…

    0 FacebookTwitterLinkedinWhatsappEmail
  • Arrays

    Insertion Sort

    by nikoo28
    4 minutes read

    Insertion sort is the most generic example of a sorting algorithm, and the one which is used by one of the most naive users. Often we must have also used this algorithm in our real life examples unknowingly. One of the favorite example is:- This is a very common scenario and we must have used it. Suppose you get a hand of cards. Our general approach is that we start scanning the cards from starting and if we find a card out of place, we remove it from there and…

    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