Data Structures Assignment: Singly and Doubly Linked Lists, Assignments of Computer Science

An assignment that requires students to implement and compare singly and doubly linked lists. The assignment includes written homework questions about lifo and fifo implementation, array vs linked list for sorted data, and computation complexity analysis. The programming part asks students to write programs for singly and doubly linked lists, with functionality to insert, delete, print in ascending and descending order. The bonus question suggests using java collections api for implementation.

Typology: Assignments

Pre 2010

Uploaded on 04/12/2010

koofers-user-1gx-1
koofers-user-1gx-1 🇺🇸

9 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Assignment 1
Written Homework:
1. How can LIFO and FIFO be implemented using singly linked list? Only consider the simple insertions
and removals.
2. What is the difference in using array and linked list when the data is to be stored in sorted order?
Discuss in terms of insertion, deletion and storage space.
3. Compute the Computation Complexity of the following using Big-Oh notation:
a. Sequential Search in an array of integers. It returns the index of the array that contains the
searched value.
int search(int[] a, int s)
{
for(int i = 0; i < a.length; i++)
if(s == a[i])
return i;
return -1;
}
b. Rectangle inclusion problem: Given a rectangle and m points. Decide how many points are
included in the rectangle.
count = 0
for each point p
if(p lies within the bounds of rectangle)
count++;
print count;
c. Nested loops
for(int i = 0; i< m; i ++)
for(int j = 0; j < n; j++)
System.out.println(m*n);
pf2

Partial preview of the text

Download Data Structures Assignment: Singly and Doubly Linked Lists and more Assignments Computer Science in PDF only on Docsity!

Assignment 1

Written Homework:

  1. How can LIFO and FIFO be implemented using singly linked list? Only consider the simple insertions and removals.
  2. What is the difference in using array and linked list when the data is to be stored in sorted order? Discuss in terms of insertion, deletion and storage space.
  3. Compute the Computation Complexity of the following using Big-Oh notation: a. Sequential Search in an array of integers. It returns the index of the array that contains the searched value. int search(int[] a, int s) { for(int i = 0; i < a.length; i++) if(s == a[i]) return i; return -1; } b. Rectangle inclusion problem: Given a rectangle and m points. Decide how many points are included in the rectangle. count = 0 for each point p if(p lies within the bounds of rectangle) count++; print count; c. Nested loops for(int i = 0; i< m; i ++) for(int j = 0; j < n; j++) System.out.println(m*n);

Programming Problem:

Data Structures

  1. Write a program to implement singly linked list sorted in ascending order, eg 1, 2, 5, 8, 8, 99, 100 You should implement yourself without making use of Collections API. The program should have the following functionality: forward reference to next node insert new number delete existing value print in ascending order print in descending order You will have to make use one of stack/queue(implement this yourself), whichever is appropriate, for one/some of the operations above. Note : The stub programs are provided. Make use of them and add your implementation in them. This includes 5 java class files: LkdList.java, LkdListTest.java, SingListNode.java, DblListNode.java, FileRdr.java will required documentations in them.
  2. Write a program with all the features of problem 1 but by using doubly linked list instead.
  3. Comment on the major differences in p1 and p2. Don't forget to indicate if there is any difference in the printing functions.

Bonus Question:

Rewrite both the programs above using Java Collections API.

Submission and grading:

The solution should include:

1. Written Homework

  1. Source code (soft copy will be collected in lab). You need to comment your code intensively and document all the algorithm level decisions and analysis in a separate report (txt file is fine). Your solution will be graded on both your program and your documentation. The code comment should be in JavaDoc style: http://java.sun.com/j2se/javadoc/writingdoccomments/.
  2. Writing Assignment which should be a free-standing essay describing how you approached the programming assignment, what you implemented, and what you learned from it. This technical writing will be judged by its quality.