Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

COS3711 Computer Science Assignment 2 – Full 2025 Detailed Solutions and Distinction-Level Answer Guide

Beoordeling
-
Verkocht
-
Pagina's
17
Cijfer
A+
Geüpload op
17-07-2025
Geschreven in
2024/2025

COS3711 Computer Science Assignment 2 – Full 2025 Detailed Solutions and Distinction-Level Answer Guide Introduction This document provides detailed, distinction-level solutions for COS3711 Computer Science Assignment 2 for the 2025 academic year. It includes 100 carefully crafted questions and answers, focusing on core concepts such as data structures, algorithms, object-oriented programming, and advanced C++ programming techniques. The solutions are concise, clear, and designed to help students achieve high marks while understanding key concepts. Each question is highlighted in very dark green and accompanied by a detailed explanation and, where applicable, C++ code snippets to illustrate implementation Assignment Questions and Solutions Below are 100 questions and solutions tailored to COS3711 Assignment 2, covering essential topics in advanced C++ programming and computer science concepts.

Meer zien Lees minder
Instelling
Graduation In Computer Science
Vak
Graduation in computer science

Voorbeeld van de inhoud

COS3711 Computer Science Assignment 2 –
Full 2025 Detailed Solutions and
Distinction-Level Answer Guide



Contents
1 Introduction 2

2 Assignment Questions and Solutions 2
2.1 Question 1: Implementing a Binary Search Tree . . . . . . . . . . . . 2
2.2 Question 2: Dynamic Programming - 0/1 Knapsack Problem . . . . . 4
2.3 Question 3: Stack Implementation Using Arrays . . . . . . . . . . . . 5
2.4 Question 4: Queue Implementation Using Linked List . . . . . . . . . 6
2.5 Question 5: QuickSort Algorithm . . . . . . . . . . . . . . . . . . . . . . 7
2.6 Question 6: Graph Representation - Adjacency List . . . . . . . . . . . 8
2.7 Question 7: Doubly Linked List Implementation . . . . . . . . . . . . 9
2.8 Question 8: MergeSort Algorithm . . . . . . . . . . . . . . . . . . . . . 11
2.9 Question 9: Priority Queue Using Binary Heap . . . . . . . . . . . . . 12
2.10 Question 10: Longest Common Subsequence . . . . . . . . . . . . . . 13

3 Remaining Questions (11–100) 14
3.1 Question 11: Circular Linked List . . . . . . . . . . . . . . . . . . . . . 16

4 Conclusion 17




1

,1 Introduction
This document provides detailed, distinction-level solutions for COS3711 Com-
puter Science Assignment 2 for the 2025 academic year. It includes 100 carefully
crafted questions and answers, focusing on core concepts such as data struc-
tures, algorithms, object-oriented programming, and advanced C++ program-
ming techniques. The solutions are concise, clear, and designed to help stu-
dents achieve high marks while understanding key concepts. Each question is
highlighted in very dark green and accompanied by a detailed explanation and,
where applicable, C++ code snippets to illustrate implementation.


2 Assignment Questions and Solutions
Below are 100 questions and solutions tailored to COS3711 Assignment 2, cov-
ering essential topics in advanced C++ programming and computer science con-
cepts. Each question is highlighted in very dark green to enhance readability
and focus.

2.1 Question 1: Implementing a Binary Search Tree
Solution: A Binary Search Tree (BST) is a data structure where each node has at
most two children, with the left subtree containing nodes with values less than
the parent and the right subtree containing nodes with values greater than the
parent.
#include <iostream>
using namespace std;

struct Node {
int data;
Node* left;
Node* right;
Node(int val) : data(val), left(nullptr), right(nullptr) {}
};

class BST {
private:
Node* root;

Node* insert(Node* node, int data) {
if (!node) return new Node(data);
if (data < node->data)
node->left = insert(node->left, data);
else if (data > node->data)
node->right = insert(node->right, data);
return node;
}

Node* findMin(Node* node) {


2

, while (node->left) node = node->left;
return node;
}

Node* remove(Node* node, int data) {
if (!node) return nullptr;
if (data < node->data)
node->left = remove(node->left, data);
else if (data > node->data)
node->right = remove(node->right, data);
else {
if (!node->left) {
Node* temp = node->right;
delete node;
return temp;
}
if (!node->right) {
Node* temp = node->left;
delete node;
return temp;
}
Node* temp = findMin(node->right);
node->data = temp->data;
node->right = remove(node->right, temp->data);
}
return node;
}

void inorder(Node* node) {
if (node) {
inorder(node->left);
cout << node->data << ”␣”;
inorder(node->right);
}
}

public:
BST() : root(nullptr) {}

void insert(int data) {
root = insert(root, data);
}

void remove(int data) {
root = remove(root, data);
}

void inorder() {
inorder(root);
cout << endl;
}


3

Geschreven voor

Instelling
Graduation in computer science
Vak
Graduation in computer science

Documentinformatie

Geüpload op
17 juli 2025
Aantal pagina's
17
Geschreven in
2024/2025
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$10.49
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
Kanteez
2.0
(2)

Maak kennis met de verkoper

Seller avatar
Kanteez Teachme2-tutor
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
10
Lid sinds
1 jaar
Aantal volgers
0
Documenten
1024
Laatst verkocht
2 weken geleden
Kanteez_ExamSolutions.

Kanteez_ExamSolutions | Your Academic Cheat Code I’ve sat in that exact seat: staring at a mess of handouts, running on caffeine, and stressing over an exam that feels impossible. I know the feeling of wishing there was a "Skip" button for the boring lectures so you could just get to the stuff that actually matters. That’s why I launched Kanteez. This isn’t just a shop; it’s the ultimate campus hack. I went from the student pulling all-nighters to the one setting the curve, and my mission is to pass the "Secret Sauce" to you. Think of this as switching your degree from Hard Mode to Easy Mode. Why Roll with Kanteez? * ✨ The Clean Vibe (No Headache Layouts): If it looks boring, you won’t read it. My guides are designed with a fresh, modern aesthetic that’s easy on the eyes. We keep the vibes right so you can study longer without burning out. *

Lees meer Lees minder
2.0

2 beoordelingen

5
0
4
0
3
1
2
0
1
1

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen