0% found this document useful (0 votes)
11 views2 pages

Assignment # 3: (Link List)

This document provides instructions for Assignment 3 on data structures and pointers for a Computer Programming course. It involves implementing a text editor using a doubly linked list. Students must create C++ functions for a linked list that allow insertion, deletion, replacement and searching of elements. They must also implement deletion, insertion, navigation, search, backspace, cut-paste and save functionality in the text editor by manipulating the linked list. The editor code and skeleton is provided in four source files for students to build upon.

Uploaded by

Nimra Batool
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Assignment # 3: (Link List)

This document provides instructions for Assignment 3 on data structures and pointers for a Computer Programming course. It involves implementing a text editor using a doubly linked list. Students must create C++ functions for a linked list that allow insertion, deletion, replacement and searching of elements. They must also implement deletion, insertion, navigation, search, backspace, cut-paste and save functionality in the text editor by manipulating the linked list. The editor code and skeleton is provided in four source files for students to build upon.

Uploaded by

Nimra Batool
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Computer Programming (CS-103) Spring 2018 Section C, D

National University of Computer and Emerging Sciences, Lahore

Assignment # 3
Struct and Pointers
Submission Dead Line: Friday 22/3/2018
 PROVIDE PROPER INDENTATION AND COMMENTS WITH YOUR CODE
 YOU MUST DEALLOCATE ALL MEMORY PROPERLY, YOUR CODE SHOULD NOT HAVE
ANY MEMORY LEAKS OR DANGLING POINTERS.
 NO ASSIGNMENT WILL BE ACCEPTED VIA EMAIL.

Head Tail

NULL
A B D ‘‘ F G L K
NULL

struct Node{
Char * data;
Node* next;
Node * prev;
}

Part A: (Link List)


Create a C++ doubly linked list (using structs) for character data and two pointers head (points to first
element of list) and tail (points to last element of list) with following functions.
1. Insertat_at_Tail: Add an element at the tail of link list.
2. Insert_Multiple: Add one or multiple elements at any given position in list.
3. Delete_at_Tail: Delete an element form the tail of list.
4. Delete_All: Search and removes all entries of an element from list. (this means actually
removing the nodes from the list)
5. Replace_All: Search and replace all entries of an element(s) from list with provided element(s).
6. Delete_Multiple: Search and delete multiple consecutive elements from list at any position.
7. Search: Search and return multiple consecutive elements from list.
Part C: (Text Editor)
You have to implement a text editor using the doubly linked list (created in Part A). Each character of
text will be stored as a node in the list.
Code Provided: You are provided with four files myconsole.h, myconsole.cpp, editor.h and editor.cpp.
Main function is written in editor file so run the program as it is. You can type any character in a given
cmd window and use the arrow keys to navigate the screen. There is a maximum window length set, in
which a user can enter characters.
The function mainEditor would be your starting point. Helper functions like
checkWhichKeyPressed are given in myconsole source files. Look at the corresponding .h file to see
their usage. There is also the point class to store the current coordinates of the screen. You can use
different methods of this class wherever required. For that you have to create an object (variable of point
type and then you can call different functions using (.) dot member access operator.
point currentPosition(0, 0); //currentPosition is an object of point type createded in
editor.cpp mainEditor function you can use this object for update of cursor position on screen.
Computer Programming (CS-103) Spring 2018 Section C, D
National University of Computer and Emerging Sciences, Lahore

What to Implement?
1. Deletion of a character from the editor and from the linked list too.
2. Insertion of a character in the editor. So if a user places the cursor in between text, characters
should get inserted. Insertion has to be done correspondingly in the linked list also.
3. Up, down, left, right arrow keys to navigate text are already implemented but you have to add any
additional logic that you require there. (For example, making the list pointer to move in both
directions if required)
4. Search (function key F1) for a string in the entered text. The user can enter a word/string to find at
the bottom of the text editor. After inputting the text, the system should search for an instance of
that string in the text (starting from the character at cursor position) and the cursor should jump to
that location where that character is found.
5. Implement backspace functionality, which should work as normal backspace key works.
6. Cut and Paste functionality
7. Save (function key F2) should save the text in a file called
8. ‘myeditor.txt’. Escape key should exit the editor. (Already implemented)
Happy Programming

You might also like