Facebook

Welcome to Lets Learn CS

Computer Science at fingertips

do-while loop

The functionality of do-while is slightly different from while and for loop.The condition of do-while is at the bottom of loop and it executes at least once even if the condition is false.The initialization of a variable loop is done before the loop block. Syntax do { set_of_statements; } while(condition);   Example 1 Say we… read more »

while loop

While loop keeps on executing the given statements as long as the condition is true.When the condition  turns out to be false then set of statements in the block never gets executed and the control goes to first line after the while block. Syntax while(condition) { set_of_statements; iteration statement; } If the condition is true,then set… read more »

for loop

Loops are control structures that are used to execute a code several times.There may be situation when we need to print series from 1-100 or we need to print our name 1000 times on screen.It will be inappropriate to use 100 or thousand  times printf for this scenario.Loops can be used to efficiently perform the task as… read more »

Decision Making Statements

Decision Making Statements are the statements that imposes one or more conditions on the expression and if the conditions evaluates to be true then specific actions are followed,if not true then some other actions are followed.They are called as decision making as it leads to a particular conclusion/decision.In C,true values are treated as non-zero i.e.1… read more »

Functions

A function is a group of statements that performs some specific task.They can be used in other programs depending on their accessibility and are ended by brackets.In order to define a function inside  a program we need to specify three things: Function Declaration Function Definition Function Calling Some functions are pre-defined like main(),printf(),scanf().We just need… read more »

Merge Sort

Merge sort is the divide and conquer method to arrange elements in the order.The steps followed in merge sort are : Divide the sequence of n elements into two sub-sequences of n/2 elements each. Sort the sub-sequences using merge sort.If the size of sequence is 1,nothing more can be done. Merge the sub-sequences to form… read more »

Bubble Sort

Bubble Sort is a sorting technique which arranges elements in the increasing order by moving across the array and swapping the adjacent elements that are out of order. The complexity of bubble sort is O(n2). The steps followed are : Move from first to the last element of array. Swap the element if it is… read more »

Quicksort

Sorting is a technique to arrange the sequence of elements either in ascending or descending order. Quicksort is an efficient way to sort elements of array.The average running time of quicksort is O(nlogn).The steps followed in quicksort are : Choose the pivot element(Say we choose the pivot element in the beginning of array).  Scan from… read more »

Operations on Binomial Heap – Decrease key

Decrease key refers to reducing the key value of any node.If we want to decrease a key in Binomial heap,we will replace the key with reduced value and will repeatedly exchange the reduced key with the parent in order to restore min-heap property.The running time to perform this operation is O(log n). Example Say we… read more »

Operations on Binomial Heap – Extract-min

In Extract-Min operation node with minimum key is deleted from the binomial heap h.The running time to extract minimum value is  O(log n).The steps followed  are : Find the root (say x) with minimum key. Delete the root. Break the binomial heap into h and h’. Perform the union operation to h and h’. Given the… read more »

Sidebar