Skip to main content

Posts

Showing posts from April, 2020

Bubble Sort in Data Structure

       ⇰  BUBBLE SORT :-  The bubble sorting technique is very simple sorting technique. However this technique is not efficient in comparision to other sorting techniques but for smaller list this technique works fine.  This sorting technique is comparison-based in which each pair of adjacent elements is compared and the elements are swapped if they are not in the desired order . Its worst case complexity is of Ο(n ^2 ) where n  is the number of items in the list.     Suppose we want to sort the elements of a list in ascending order, the bubble sort loops through the element in the list and compares the adjecent element and moves the smaller element to the the top of the list. EXAMPLE :- Let us take a unsorted list :-     4 3 5 2 1  ⇰    ALGORITHM OF BUBBLE SORT :- Variable used :- list= array of element, n= number of element in the list. I, J, temp = local variable. Step1 :- Initi...

Tree Traversal

        ⇰   TREE TRAVERSAL :- Tree Traversal refers to the process of visiting each node in a tree data structure exactly once.  You might for instance want to add all the values in the tree or find the largest one. For all these operations, you will need to visit each node of the tree atleast and exectly once. Linear data structures like arrays, stacks, queues and linked list have only one logical way to read the data. But a hierarchical data structure like a tree can be traversed in different ways.  Following are the generally used Techniques for traversing trees :-    i>Breadth First Traverse.  ii> Depth First Traverse. i > Breadth First Traverse :- Breadth First Traverse of a tree is technique of printing all the nodes of a tree level by level. It  is also called as   Level Order Traversal .   Here if we traverse in above tree by breadth first trev...

Segmentation In Operating System

      ⇰     SEGMENTATION :- In operating system segmentation is a memory management technique in which,    the memory is divided into the variable size parts. Each part is known as segment which can be allocated to a process.  Each segment is actually a different logical address space of the program. When a process want to be executed, its corresponding segmentation are loaded into non-contiguous memory, though every segment is loaded into a contiguous block of available memory.     Segmentation memory management technique is somehow works similar to the paging technique. But here difference is that the every segment is of different length where as in paging, pages are of fixed size or same size.  A program segment contains the program's main function, utility functions, data structures, and many others.    The details about each segment are stored in a table called as segment table which is ...

Paging In Operating System

       ⇰  PAGING :-    In Operation System, paging is actually a memory management scheme that eliminates the need for contiguous memory allocation. It permits the physical address space of a process to be non–contiguous type.   Paging  also solves the considerable problem of fitting memory chunks of varying sizes onto the backing store. Most memory management schemes before the introduction of paging suffered from this problem. The problem arises because, when data residing in main memory need to be swapped out, space must be found on the backing store. The backing store has the same fragmentation problems. However, paging avoids external fragmentation   The basic method for implementing paging involves breaking physical memory or main memory  into fixed-sized blocks called frames and breaking logical memory or secondary memory ( Harddisk)  into blocks of the same size called page...

Selection Sort In Data Structure

   ⇰  SELECTION SORT :- Selection sort is one of the simple type of sorting algorithm. This sorting algorithm is based on In-place comparision of element in the array. In this technique the smallest element is selected from the unsorted array and swapped with the leftmost element. This process continues moving unsorted array boundary by one element to the right. The selection starts from first element and searches the entire list or array until it finds the minimum value in the first place, again selects the second element and searches for the second samllest element. This process continues untill the complete list becomes sort form.This algorithm is not suitable for large data as insertion sort. Its  worst case complexity is Ο(n 2 ), where n is the number of items. FOR EXAMPLE :- Let us take a unsorted list :-      4 3 5 2 1   ⇰  ALGORITHM OF SELECTION SORT :- Variable used:-  array= list of element, si...

Contigeous Memory Allocation

  The main memory must accommodate or store both the operating system and the various user processes. So we need to allocate main memory in the most efficient way possible. As we know the memory is usually divided into two partitions: one for the operating system and other for the user processes. We can place the operating system in either low memory or high memory. Since the interrupt vector is often in low memory, programmers usually like to place the operating system in low memory.   We usually want several user processes to reside in memory at the same time. We therefore need to consider how to allocate available memory to the processes that are in the input queue waiting to enter into memory. In contiguous memory allocation, each process is contained in a single section of memory that is contiguous to the section containing the next process.  Thus we can say if the blocks are allocated to the file in such a way that all the logical blocks of the file get the ...

Types Of Memory Allocation

  Now we are ready to read about various types of memory allocation. One of the simplest  methods for allocating memory is to divide memory into several Fixed-Sized  partitions. Each partition may contain exactly one process.  In this multiple partition  method, when a partition is free, a process is selected from the input  queue and is loaded into the free partition. When the process terminates, the  partition becomes available for another process. But this method is  no longer in use.   In the Variable-Partition scheme, the operating system keeps a table  indicating which parts of memory are available and which are occupied.  All the memory is available for user processes and is considered one  large block of available memory, called hole. Eventually memory  contains a set of holes of various sizes.  As processes enter the system, they are put into an input queue. And when a process is allocated space, it is ...