Recently Added

DSA assignment

KRISHNA

 Define Data structure and also write down the difference between primitive and non-primitive data structure.

What is an algorithm? Distinguish between a program and an algorithm.

Implement an array in C, supporting insertion at the

beginning

at the specific position

Define the complexity of an algorithm. Also explain time and space complexity in detail.

Write a program in C to implement Bubble sort in a one-dimensional array.

Explain the Asymptotic Notation.

What do you mean by best, worst and average case analysis of an algorithm?

Codes for lab

KRISHNA

 Bubble sort..


// C program for implementation of Bubble sort

#include <stdio.h>


void swap(int* arr, int i, int j) {

    int temp = arr[i];

    arr[i] = arr[j];

    arr[j] = temp;

}


void bubbleSort(int arr[], int n) {

    for (int i = 0; i < n - 1; i++) {

      

        // Last i elements are already in place, so the loop

        // will only num n - i - 1 times

        for (int j = 0; j < n - i - 1; j++) {

            if (arr[j] > arr[j + 1])

                swap(arr, j, j + 1);

        }

    }

}


int main() {

    int arr[] = { 6, 0, 3, 5 };

    int n = sizeof(arr) / sizeof(arr[0]);


    // Calling bubble sort on array arr

    bubbleSort(arr, n);


    for (int i = 0; i < n; i++)

        printf("%d

 ", arr[i]);


    return 0;

}






Insertion short 


// C++ program for implementation of Insertion Sort

#include <iostream>

using namespace std;


/* Function to sort array using insertion sort */

void insertionSort(int arr[], int n)

{

    for (int i = 1; i < n; ++i) {

        int key = arr[i];

        int j = i - 1;


        /* Move elements of arr[0..i-1], that are

           greater than key, to one position ahead

           of their current position */

        while (j >= 0 && arr[j] > key) {

            arr[j + 1] = arr[j];

            j = j - 1;

        }

        arr[j + 1] = key;

    }

}


/* A utility function to print array of size n */

void printArray(int arr[], int n)

{

    for (int i = 0; i < n; ++i)

        cout << arr[i] << " ";

    cout << endl;

}


// Driver method

int main()

{

    int arr[] = { 12, 11, 13, 5, 6 };

    int n = sizeof(arr) / sizeof(arr[0]);


    insertionSort(arr, n);

    printArray(arr, n);


    return 0;

}





Selection short


// C++ program to implement Selection Sort

#include <bits/stdc++.h>

using namespace std;


void selectionSort(vector<int> &arr) {

    int n = arr.size();


    for (int i = 0; i < n - 1; ++i) {


        // Assume the current position holds

        // the minimum element

        int min_idx = i;


        // Iterate through the unsorted portion

        // to find the actual minimum

        for (int j = i + 1; j < n; ++j) {

            if (arr[j] < arr[min_idx]) {


                // Update min_idx if a smaller

                // element is found

                min_idx = j; 

            }

        }


        // Move minimum element to its

        // correct position

        swap(arr[i], arr[min_idx]);

    }

}


void printArray(vector<int> &arr) {

    for (int &val : arr) {

        cout << val << " ";

    }

    cout << endl;

}


int main() {

    vector<int> arr = {64, 25, 12, 22, 11};


    cout << "Original array: ";

    printArray(arr); 


    selectionSort(arr);


    cout << "Sorted ar

ray: ";

    printArray(arr);


    return 0;

}




Inserting a particular element at a particular position in an array.

#include <iostream>

using namespace std;


int main() {

    int size, element, position;


    // Enter the size of the array

    cout << "Enter the size of the array: ";

    cin >> size;


    int arr[size + 1]; // Array with an extra space for the new element


    // Input the elements of the array

    cout << "Enter the elements of the array:\n";

    for(int i = 0; i < size; i++) {

        cin >> arr[i];

    }


    // Enter the element to be inserted and the position

    cout << "Enter the element to be inserted: ";

    cin >> element;

    cout << "Enter the position to insert the element (0-based index): ";

    cin >> position;


    // Check if the position is valid

    if(position < 0 || position > size) {

        cout << "Invalid position!" << endl;

        return 1;

    }


    // Shift elements to the right

    for(int i = size; i > position; i--) {

        arr[i] = arr[i - 1];

    }


    // Insert the element at the given position

    arr[position] = element;


    // Display the updated array

    cout << "Array after insertion:\n";

    for(int i = 0; i <= size; i++) {

        cout << arr[i] << " ";


    }

    cout << endl;


    return 0;

}





Deletion at a particular position in an array.


#include <iostream>

using namespace std;


int main() {

    int size, position;


    // Enter the size of the array

    cout << "Enter the size of the array: ";

    cin >> size;


    int arr[size]; // Array with the specified size


    // Input the elements of the array

    cout << "Enter the elements of the array:\n";

    for(int i = 0; i < size; i++) {

        cin >> arr[i];

    }


    // Enter the position to delete the element

    cout << "Enter the position to delete the element (0-based index): ";

    cin >> position;


    // Check if the position is valid

    if(position < 0 || position >= size) {

        cout << "Invalid position!" << endl;

        return 1;

    }


    // Shift elements to the left from the position specified

    for(int i = position; i < size - 1; i++) {

        arr[i] = arr[i + 1];

    }


    // Display the updated array

    cout << "Array after deletion:\n";

    for(int i = 0; i < size - 1; i++) {

        cout << arr[i] << " ";

   

 }

    cout << endl;


    return 0;

}



BCS302: Computer Organization & Architecture

KRISHNA

                BCS302: Computer Organization & Architecture


___________________________________________________________________________________

UNIT 1:


Introduction: 

Functional units of digital system and their interconnections, 

buses, 

bus architecture, 

types of buses 

and bus arbitration. 

Register, 

bus and memory transfer. 

Processor organization, 

general registers organization, 

stack organization 

and addressing modes


___________________________________________________________________________________


                                                                  UNIT 2:


Arithmetic and logic unit: 

Look ahead carries adders. 

Multiplication: 

Signed operand multiplication, 

Booths algorithm and array multiplier. 

Division and logic operations. 

Floating point arithmetic operation, 

Arithmetic & logic unit design. 

IEEE Standard for Floating Point Numbers


___________________________________________________________________________________


                                                                  UNIT 3:


Control Unit: 

Instruction types, 

formats, 

instruction cycles 

and sub cycles (fetch and execute etc), 

micro operations, 

execution of a complete instruction. 

Program Control, 

Reduced Instruction Set Computer, 

Pipelining. 

Hardwire and micro programmed control: 

micro programme sequencing, 

concept of horizontal and 

vertical microprogramming


___________________________________________________________________________________


                                                                  UNIT 4:


Memory: 

Basic concept and hierarchy, 

semiconductor RAM memories, 

2D & 2 1/2D memory organization. 

ROM memories. 


Cache memories: 

concept and design issues & performance, 

address mapping 

and replacement Auxiliary memories: 

magnetic disk, 

magnetic tape and optical disks 


Virtual memory: concept implementation.


___________________________________________________________________________________


                                                                  UNIT 5:


Input / Output: 

Peripheral devices, 

I/O interface, 

I/O ports, 


Interrupts: 

interrupt hardware, 

types of interrupts and exceptions. 


Modes of Data Transfer: 

Programmed I/O, 

interrupt initiated I/O and Direct Memory Access., 

I/O channels and processors. 


Serial Communication: 

Synchronous & asynchronous communication, 

standard communication interfaces. 



-------------------------------------------------------------------------------------------------------------------


Our Team

  • REHMAAN BHAICR
  • Krishna Kumar UpadhyaySite Managment
  • Vikrant SinghPhysical Supporter
  • Vikash PatelIdeas and Visuals
  • Utkarsh SharmaData Supporter
  • Prashant SinghEconomical Supporter