الكويت البحرين عمان الأردن لبنان مصر البحرين حائل الرياض الدمام جدة المدينة المنورة الاحساء
(.turnitin./ ) فحص التشابه وفقا لنظام الجامعة عن طريق موقع كشف التشابه
حل واجب 0.5.4.4.3.2.1.4.5.5 الجامعة العربية المفتوحة
حل واجبات الجامعة العربية المفتوحة O54.4.3.2.1.4.5.5 - OO96654.4.3.2.1.4.5.5
ايميل : a_al_shora @ h.o.t.m.ail.c.o.m
سكايبي: a_al_shora
واتس اب: OO96654.4.0.5.0.8.9.7
M180: Data Structure and Algorithms in Java
Tutor-Marked Assignment (Summer 2014/2015)
Cut-Off Date:
Total Marks: 40
Contents
Warnings and Declaration………………………………………………………………………………..1
Question 1……………..……………………….………………………………………………………….2
Question 2 ………………..…………………………………………………………………………….….2
Question 3 ………….………..………………………………………………………………………….….3
Question 4 ………….…………..……………………………………………………………………….….3
Question 5 ………….…………..……………………………………………………………………….….4
Question 6 ………….…………..……………………………………………………………………….….4
Plagiarism Warning:
As per AOU rules and regulations, all students are required to submit their own TMA work and avoid plagiarism. The AOU has implemented sophisticated techniques for plagiarism detection. You must provide all references in case you use and quote another person's work in your TMA. You will be penalized for any act of plagiarism as per the AOU's rules and regulations.
Declaration of No Plagiarism by Student (to be signed and submitted by student with TMA work):
I hereby declare that this submitted TMA work is a result of my own efforts and I have not plagiarized any other person's work. I have provided all references of information that I have used and quoted in my TMA work.
Name of Student:………………………………..
Signature:…………………………………………...
Date:……………………………………………………
Question 1: (4 marks)
Some have stated that linked lists are much better than arrays. If that is always a valid statement, then why are arrays used at all?
As a conclusion of what you have learnt about them, you are asked to compare the Arrays with Linked lists in terms of one of the following: access restrictions, ease of search, insert or delete operations. Give an example to support your answer.
Question 2: (5 marks)
You are given a Node class and a List class:
public class Node
{
int data;
Node next;
}
public class List
{
Node first;
}
Provide a certain code that will turn the "Initial state " diagram into the "Final state" diagram by modifying links between the nodes shown and/or creating new nodes as needed. There may be more than one way to write the code, but you are NOT allowed to change any existing node' data field value.
Question 3: (9 marks)
a. Write a Java recursive function that returns the sum of the first n elements of the array array1.
Assume that n is always less than the physical size of array1.
b. draw the decomposition & composition of sum( array1,4) , for array1={1,-5,2,7,3,5,8}
Question 4: (9 marks)
For each of the following, give the time complexity using Big-O notation and explain your answer. Consider that we always have n>m.
Note that the running time corresponds here to the number of times the operation sum++ is executed.
sum = 0;
for(i=0; i System.out.println(“*”);
for(j=0; j for(k=0; k<10; k=k+2)
sum++;}
sum = 100;
for(i=0; i sum++;
}
for(j=10; j for(k=1; k sum++;
sum = 0;
for(i=2; i for(j=3; j sum++;}}
for(k=1; k sum++;
Question 5: (9 marks)
You are supposed to write a method mirrorDoubled that accepts a stack of integers as a parameter and replaces the stack contents with itself plus the doubles of its numbers (doubles of the elements , and placed in the opposite order).
For example, suppose a variable s stores the following elements:
bottom [10, 5, 9, 4, 6, 7] top
After a call of mirrorDoubled (s); , the stack would store the following elements (doubles are underlined for emphasis):
bottom [10, 5, 9, 4, 6, 7, 14, 12, 8, 18, 10, 20] top
Note that the doubled numbers are added on to the top of what was originally in the stack. The bottom half of the stack contains the original numbers in the same order.
If your method is passed an empty stack, the result should be an empty stack.
If your method is passed a null stack, your method should throw an IllegalArgumentException.
You are asked to write the method mirrorDoubled using one temporary stack and one queue.
Question 6: (4 marks)
Given the following recursive function:
public static double trick(int n) {
return trick(n-1) + 1.0/n;
}
Call the above function using n= 4, and detect the missing part in this code?
End of Assessment
حل واجبات الجامعة العربية المفتوحة
حل واجبات الجامعه العربية المفتوحه مع الشرح
لجميع فروع الجامعة ولجميع التخصصات ولجميع المواد
الكويت البحرين عمان الأردن لبنان مصر البحرين حائل الرياض الدمام جدة المدينة المنورة الاحساء
(.turnitin./ ) فحص التشابه وفقا لنظام الجامعة عن طريق موقع كشف التشابه