Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

Program a c++ code about using the brute force exhaustive search algorithmic techniques and do time and space complexity analysis Topic: Student course and marks

Program a c++ code about using the brute force\ exhaustive search algorithmic techniques and do time and space complexity analysis

Topic: Student course and marks

We will discuss the problem of course and marks in this project. First, we will search the student's information. Next, we will search the titles of the materials the student registered for and his grades there. Finally, we will take all of the grades and do mathematical operations to determine the student's overall grades.

The code:

#include

#include

struct Student {

std::string name;

std::vector courses;

std::vector grades;

};

std::vector students;

void search() {

std::string searchName;

std::cout << "Enter student name: ";

std::cin >> searchName;

for (const auto& student : students) {

if (student.name == searchName) {

std::cout << "Student found:" << std::endl;

std::cout << "Name: " << student.name << std::endl;

std::cout << "Courses: ";

for (const auto& course : student.courses) {

std::cout << course << " ";

}

std::cout << std::endl;

std::cout << "Grades: ";

for (const auto& grade : student.grades) {

std::cout << grade << " ";

}

std::cout << std::endl;

double overall_grade = 0;

for (const auto& grade : student.grades) {

overall_grade += grade;

}

overall_grade /= student.grades.size();

std::cout << "Overall grade: " << overall_grade << std::endl;

return;

}

}

std::cout << "Student not found." << std::endl;

}

int main() {

// populate the students vector with sample data

students.push_back({ "Alice", {"Math", "Physics", "Chemistry"}, {90, 80, 85} });

students.push_back({ "Bob", {"English", "History", "Art"}, {70, 75, 80} });

students.push_back({ "Charlie", {"Computer Science", "Electronics", "Biology"}, {65, 70, 75} });

search();

}

The output:

This code defines a Student struct that contains the student's name, a vector of courses, and a vector of grades. It also contains a global vector of students that is populated with some sample data. The search function prompts the user for a student name and then uses a for-loop to iterate through the vector of students.

Explanation:

For each student, it compares the student's name to the search name. If there is a match, the function prints out the student's name, courses, and grades. It also prints the overall grade of the student and return otherwise it print student not found.

can you help me to do the following requirements:please

Your project should create a students' courses and marks database and should have the following functionalities:

1. Sort according to the student's names and Ids

2. Search the students' database by course id for the student list and corresponding marks

3. Search by student's marks

Use a suitable data structure such as, BST, heap or others to store the database and perform the above operations using appropriate algorithms.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions