Showing posts with label DSL. Show all posts
Showing posts with label DSL. Show all posts

Tuesday, 15 July 2025

In an e-commerce system, customer account IDs are stored in a list write a program to search customer id using linear and binary search.

 Savitribai Phule Pune University

Second Year of Computer Engineering and Computer Science and Engineering (2024 Course)

PCC-201A COM: Data Structures Laboratory


Problem Statement:

In an e-commerce system, customer account IDs are stored in a list, and you are tasked with

writing a program that implements the following:

a) Linear Search: Check if a particular customer account ID exists in the list.

b) Binary Search: Implement Binary search to find if a customer account ID exists,

improving the search efficiency over the basic linear


Algorithm:

1. Linear Search:

1. Start

2. Accept Customer ID from user that you want to search in e-commerce system i:e target_id

3. You have to check one by one linearly that  target_id is present inside the Customer_Id list. 

    3.1 if it is present then print or show target _id is present at nth index. or 

    3.2 if all customer_id scanned or checked and still if you are not getting match of target_id then just print or show customer_id is not present.

4. Stop


2. Binary Search:

1. Start

2. For Binary Search all elements inside the list must be in sorted order. hence sort the list (if not already sorted).

3.  Set low = 0 (start index of the list).

4.  Set high = length of the list - 1 (end index).

5.  While low is less than or equal to high, do:

5.1      Calculate mid = (low + high) // 2.

5.2       If the element at mid is equal to the target:

5.2.1    Return mid (target found).

5.3        Else if element at mid is less than the target:

5.3.1    Set low = mid + 1 (search in right half).

5.4      Else:

5.4.1    Set high = mid - 1 (search in left half).

6.  If the loop ends and the target is not found:

6.1      Return -1.


Implementation:









Monday, 7 July 2025

Implement student database using dynamically allocated memory and perform various operations.

 NEP 2020 Compliant Curriculum Structure

Second Year Engineering (2024 Pattern) – Information Technology


1. Title:
Implement student database using dynamically allocated memory.

2. Objective:
Study various data structures and do the implementation of specific applications.


3. Problem Statement:

Design a program to maintain a student database that performs the following tasks: 

1. Add and store student details (ID, Name, CGPA) using dynamically allocated memory.

2. Expand the student list using realloc () as new entries are added.

3. Implement Linear Search and Binary Search to find student records by ID.

4. Implement at least two Sorting Algorithms (Bubble Sort, Selection Sort, or Insertion Sort) to sort student records by: 1. Name (Alphabetically) 2. CGPA (Ascending/Descending)

5. Analyze and compare the performance of search operations before and after sorting.


4. Outcomes:

After implementing the above problem statement, the expected outcome are as follows:

1. We learn how to allocate memory dynamically and then we store student details in it like id, name, CGPA.

2. We learn how to reallocate memory that is expansion of student list using realloc() function. for e.g. first, we allocate only 10bytes of memory but right now we want to store one more record but there is no sufficient memory so once again we do the reallocation of memory means expansion of memory and store the record.

3. We learn how to search particular student from the list of students by using two searching technique Linear Search and Binary Search.

4. We learn how to sort (Ascending /Descending) the student record using three sorting techniques 1. Bubble Sort 2. Selection Sort and 3. Insertion Sort.

5. We analyze and able to do the comparisons of performance of search operations before and after sorting.


5. Algorithms:



Saturday, 21 June 2025

Group A: Library Management System using Python (SPPU SE Computer New Syllabus 2024 PAT)

National Education Policy (NEP)-2020 Compliant Curriculum
SE - Second Year Engineering (2024 Pattern) 
in
Computer Engineering
&
Computer Science and Engineering


Problem Statement:

Write a Python program to manage the borrowing records of books in a library. Implement the following functionalities:

 • Compute the average number of books borrowed by all library members. 

 • Find the book with the highest and lowest number of borrowings 

    in the library. 

 • Count the number of members who have not borrowed any books 

    (denoted by a borrow count of 0). 

 • Display the most frequently borrowed book (i.e. the mode of 

    borrow counts).

 After performing, determine the time and Space complexity of each operation


Dear Reader,

By reading the above problem statement, we come to know that we want to implement Library Management System using Python Programming language with some specific functionalities.


Algorithm:

First thing we need to implement Class with some basic functionalities.
1. Types of Data Structures we are using such as Dictionary, Nested Dictionary, List of      Tuples.
2. Basic Functionalities are as follows:
    2.1 Register Users or Enroll users inside the library.
    2.2 Display all the enrolled or registered users from the library.
    2.3 Add book information inside the library.
    2.4 Display all books information added inside the library.
    2.5 Borrow book functionality through which user can borrow books available                      inside library.
    2.6 Display the borrow log of books.
3. Finding the book with the highest and lowest number of borrowings in the library.
4. Display the most frequently borrowed book.
5. Count the number of members who have not borrowed any books.
6. Compute the average number of books borrowed by all library members.


Let's start the implementation of above problem statement.

1. Types of Data Structures we are using such as Dictionary, Nested Dictionary, List of      Tuples.




2. Basic Functionalities are as follows:
    2.1 Register Users or Enroll users inside the library.
    2.2 Display all the enrolled or registered users from the library.
    2.3 Add book information inside the library.
    2.4 Display all books information added inside the library.
    2.5 Borrow book functionality through which user can borrow books available                      inside library.
    2.6 Display the borrow log of books.




3. Finding the book with the highest and lowest number of borrowings in the library.



From line number 96 we have created the object (nmshivalelibrary) of MyLibrary Class and through that object we are calling all member function of that respective MyLibrary class.



After calling all the member functions let's check how our code is going to execute. let's understand it through below output:




4. Display the most frequently borrowed book.

Algorithm:
1. Start

2. First check is their book in books dictionary, if not say No books else go to next step.

3. As we know in book dictionary, we store every book information along with book id - book name and it borrow count. for e.g. 101, {'book_name':'TOC', 'borrow_count': 2} 
we also know dictionary stores data in key value pair so here book id is key and remaining like book_name and borrow_count acts as a value. now from this value we want to find out the max borrow_count for that purpose we write lambda function inside max function so that we will get max value of borrow count.

4. once we get the max value i:e max_borrow from borrow_count of books dictionary then we will search for book name of that particular max_borrow from book_name and stored it inside most_borrowed variable.

5. finally we display the most borrowed book or frequently borrowed book.


By referring the code of above function, we can find out the most frequently borrowed book.

5. Count the number of members who have not borrowed any books.

Algorithm:

1. Start

2. First of all, from the borrower_log you have to find out the user id of users who borrow the book into the set of borrowed_user_ids. To do this we iterate inside the borrower_log list where we store user_id and book_id in tuple format like (user_id, book_id).

3. Now from that tuple we just want to deal with 0th index record of each tuple so to do this we have written a code like user_id = record [0] by doing this we are just collecting the user id from borrower_log and store it inside the borrower_user_ids set using add ( ) method

4. Once we get all user ids from borrower_log next, we have to search user_id from user's dictionary who is not in  borrower_user_ids set. Those who are not in borrower_user_ids set we put or store them inside users_without_books list.

5. finally we display them as users who have not issued or borrowed any book with its user id and username.

6. Stop




6. Compute the average number of books borrowed by all library members.

Algorithm:

1. Start

2. Find out the total number of books borrowed in sum_of_book_borrow

3. Find the length of number of users registered inside library system in 
    no_of_lib_members

4. Find out the average = (sum_of_book_borrow / no_of_lib_members)

5. Show the computed average number of books borrowed by 
    all library members.

6. Stop




Note: Dear readers if you have any suggestion, please guide me for the same write your comment in comment box so that I can correct myself. Thanking you in advance.