قديم منذ /21-04-2017, 01:01 AM   #1

طالب جديد

Malak ammar غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 7562
 تاريخ الإنتساب : Dec 2013
 المشاركات : 13
 الجنس : أنثى
 مستوى التقييم : Malak ammar is on a distinguished road
النقاط : 0

شكراً: 0
تم شكره مرة واحدة في مشاركة واحدة
Unhappy Assignment 3


السلام عليكم

ياريت اللي يقدر يساعدنا بحل الاسايمنت 3

Question One
A)What is the Output of the following Linear (Sequential) Search program? It searches the given array for the number 52. [2.5 mark points]
B)Write the one (or more) line of code that you would change in this program, so it will only output the first occurrence of the number 52 and then stops. [2.5 mark points]

import java.util.*;

public class MySeqSearch **

public static void main(String[] args)
**
int[] a = {99, 101, 8, -22, 3, 55, 42, -1, 0, 52, 33, -4, 66, 1, 52**;

System.out.println(Arrays.toString(a));

int n = 52;
System.out.println("Searching for number: " + n );


boolean found = false;
int i = 0;

while (!found || i < a.length )
**
if (a[i] == n)
**
System.out.println(n + " is Found at index position " + i);
found = true;
**
i++;
**

if ( !found)
System.out.println(n + " was Not Found!");

**
**


Question Two
Part A) Calculate the Big Oh performance for the Sequential Search on the array given below that has 15 elements? Given that sequential search of an array of 10 elements took on average 1 second. [2.5 mark points]
[ 99, 101, 8, -22, 3, 55, 42, -1, 0, 52, 33, -4, 66, 1, 52]
Part B) Calculate the Big Oh performance for the Binary Search on the sorted array given below that has 15 elements? Given that Binary search of an array of 10 elements took on average 1 second. [2.5 mark points]
[ -22, -4, -1, 0, 1, 3, 8, 22, 42, 52, 52, 55, 66, 99, 101]
Question Three
Write a complete program that creates two stacks with the following element:
s1 = {10, 3, 1, 5**
s2 = {7, 9, 2, 8, 12, 4**
Use the pop method to extract the top element from each stack and print the summation of these two elements. Finally, print the remaining elements from both stacks, indicate if empty or show what is left in the stack.
Sample Output:

Question Four
Part (A) Draw a diagram of a linked list that contains the following city nodes: “Jeddah”, “Mecca” and “Dammam”. Include an instance variable (pointer) to indicate the beginning of the list. In addition, for each element, clearly show its fields, contents and the references. [2.5 mark points]
Part B) List three differences between Linked List structure and Array structure? Include the differences of: 1. How we add/remove elements in each. 2. Differences in structure itself 3. How each access its elements. [2.5 mark points]

NOTE: You can use MS Word or any diagraming tool to draw. Or simply “hand” drawing. Then, take picture snapshot and paste your diagram here.

Question Five
Using a LinkedList and ListIterator classes from the java library packages. Write a program that contains a list of courses’ codes. Your program should do the following functions in order.

1.Add the following courses in the list: “CS141”, “CS140” and “IT409”.
2.Remove the course “CS141” from the list and return it in “removed” variable.
3.Add the course “IT448” after the course “CS140”.
4.Prints all the courses in the list using ListIterator object.










  رد مع اقتباس
الأعضاء الذين قالوا شكراً لـ Malak ammar على المشاركة المفيدة:

قديم منذ /21-04-2017, 03:13 PM   #2

 
الصورة الرمزية Jazmien
طالب نشيط

Jazmien غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 15836
 تاريخ الإنتساب : Jul 2015
 مقر الإقامة : الجبيل
 فرع الجامعة : فرع الدمام
 التخصص : بكالوريوس إدارة الأعمال
 المستوى : المستوى الثامن
 المشاركات : 107
 الجنس : أنثى
 مستوى التقييم : Jazmien will become famous soon enough
النقاط : 32

شكراً: 54
تم شكره 38 مرة في 16 مشاركة
افتراضي


لو شرحت لنا مدرستنا الاسئلة راح انقل الشرح لكم إن شاء الله








  رد مع اقتباس
قديم منذ /24-04-2017, 01:52 AM   #3

طالب جديد

ساره محمود غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 25055
 تاريخ الإنتساب : Nov 2016
 المشاركات : 9
 الجنس : أنثى
 مستوى التقييم : ساره محمود is on a distinguished road
النقاط : 0

شكراً: 0
تم شكره 0 مرة في 0 مشاركة
افتراضي


ياليت تساعدونا الله يوفقكم








الملفات المرفقة
نوع الملف: docx CS141-Assignments3.docx‏ (261.1 كيلوبايت, المشاهدات 30)
  رد مع اقتباس
قديم منذ /25-04-2017, 02:06 PM   #4

طالب جديد

Yasmeen Ali غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 18129
 تاريخ الإنتساب : Oct 2015
 المشاركات : 9
 الجنس : أنثى
 مستوى التقييم : Yasmeen Ali is on a distinguished road
النقاط : 0

شكراً: 2
تم شكره 4 مرة في مشاركة واحدة
افتراضي


جواب السؤال الاول
a-
[99, 101, 8, -22, 3, 55, 42, -1, 0, 52, 33, -4, 66, 1, 52]
Searching for number: 52
52 is Found at index position 9
52 is Found at index position 14

b-
if (a[i] == n)
**
System.out.println(n + " is Found at index position " + i);
found = true;
break;
**








  رد مع اقتباس
قديم منذ /26-04-2017, 01:21 AM   #5

طالب جديد

hawra_radi غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 11374
 تاريخ الإنتساب : Sep 2014
 المشاركات : 43
 الجنس : أنثى
 مستوى التقييم : hawra_radi is on a distinguished road
النقاط : 0

شكراً: 0
تم شكره 0 مرة في 0 مشاركة
Thumbs up


اقتباس:
المشاركة الأصلية كتبت بواسطة yasmeen ali مشاهدة المشاركة
جواب السؤال الاول
a-
[99, 101, 8, -22, 3, 55, 42, -1, 0, 52, 33, -4, 66, 1, 52]
searching for number: 52
52 is found at index position 9
52 is found at index position 14

b-
if (a[i] == n)
**
system.out.println(n + " is found at index position " + i);
found = true;
break;
**
يعطيك العافيه الله يجزاك كل خير







  رد مع اقتباس
قديم منذ /26-04-2017, 06:47 PM   #6

طالب جديد

SUN TOP غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 18420
 تاريخ الإنتساب : Oct 2015
 المشاركات : 2
 الجنس : ذكر
 مستوى التقييم : SUN TOP is on a distinguished road
النقاط : 0

شكراً: 9
تم شكره 0 مرة في 0 مشاركة
افتراضي


Question Two
Part A) Calculate the Big Oh performance for the Sequential Search on the array given below that has 15 elements? Given that sequential search of an array of 10 elements took on average 1 second. [2.5 mark points]
[ 99, 101, 8, -22, 3, 55, 42, -1, 0, 52, 33, -4, 66, 1, 52]

15 / 10 = 1.5 times
So O(n)=1.5*1=1.5 second

Part B) Calculate the Big Oh performance for the Binary Search on the sorted array given below that has 15 elements? Given that Binary search of an array of 10 elements took on average 1 second. [2.5 mark points]
[ -22, -4, -1, 0, 1, 3, 8, 22, 42, 52, 52, 55, 66, 99, 101]

log(15 )/ log(10) = 1.176 times
So O(log n)=1.761*1=1.176 second








  رد مع اقتباس
قديم منذ /26-04-2017, 11:03 PM   #7

طالب نشيط

Ali.Jassim غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 16313
 تاريخ الإنتساب : Aug 2015
 مقر الإقامة : -AlQatif
 فرع الجامعة : فرع الدمام
 التخصص : بكالوريوس تقنية معلومات
 المستوى : المستوى السابع
 المشاركات : 194
 الجنس : ذكر
 مستوى التقييم : Ali.Jassim will become famous soon enough
النقاط : 32

شكراً: 11
تم شكره 21 مرة في 11 مشاركة
افتراضي


اقتباس:
المشاركة الأصلية كتبت بواسطة sun top مشاهدة المشاركة
question two
part a) calculate the big oh performance for the sequential search on the array given below that has 15 elements? Given that sequential search of an array of 10 elements took on average 1 second. [2.5 mark points]
[ 99, 101, 8, -22, 3, 55, 42, -1, 0, 52, 33, -4, 66, 1, 52]

15 / 10 = 1.5 times
so o(n)=1.5*1=1.5 second

part b) calculate the big oh performance for the binary search on the sorted array given below that has 15 elements? Given that binary search of an array of 10 elements took on average 1 second. [2.5 mark points]
[ -22, -4, -1, 0, 1, 3, 8, 22, 42, 52, 52, 55, 66, 99, 101]

log(15 )/ log(10) = 1.176 times
so o(log n)=1.761*1=1.176 second

مرحبا ... هل ممكن تقول لي من وين حصلت على هذه الاجابة ؟
يعني هل في أمثله طبقتها مشابهه لهذا المثال ؟
شكرا لك مقدما







التوقيع
اللهم صل على محمد وآل محمد
اللهم اجعلنا من العلماء الصالحين في الدنيا والاخرة

العلم يحرسك وأنت تحرس المال , العلم يزكو على الإنفاق والمال تنقصه النفقة العلم حاكم والمال محكوم عليه’ ومحبة العلم دين يدان بها , العلم يكسب العالم الطاعة في حياته
  رد مع اقتباس
قديم منذ /27-04-2017, 04:07 AM   #8

طالب جديد

Turki_81 غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 15839
 تاريخ الإنتساب : Jul 2015
 المشاركات : 25
 الجنس : ذكر
 مستوى التقييم : Turki_81 is on a distinguished road
النقاط : 0

شكراً: 3
تم شكره 0 مرة في 0 مشاركة
افتراضي


اقتباس:
المشاركة الأصلية كتبت بواسطة Ali.Jassim مشاهدة المشاركة
مرحبا ... هل ممكن تقول لي من وين حصلت على هذه الاجابة ؟
يعني هل في أمثله طبقتها مشابهه لهذا المثال ؟
شكرا لك مقدما
Big O(N) for sequential search on the array
we use O(n) to find the time in sec, where "n" is the number of elements

Big O(n) for Binary search on sorted array
we use log(n) to find the time in sec, where "n" is also the number of the elements
: by data was given in this Q we'll find
n = 15 , n1=10
t= ? , t1=1

and you can find in attached how to calculate Big O notation


..G.Luck..







الملفات المرفقة
نوع الملف: pdf Big O notation 2.pdf‏ (1.67 ميجابايت, المشاهدات 55)
  رد مع اقتباس
قديم منذ /27-04-2017, 04:10 AM   #9

طالب جديد

Turki_81 غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 15839
 تاريخ الإنتساب : Jul 2015
 المشاركات : 25
 الجنس : ذكر
 مستوى التقييم : Turki_81 is on a distinguished road
النقاط : 0

شكراً: 3
تم شكره 0 مرة في 0 مشاركة
افتراضي


In which question do you need help ??








  رد مع اقتباس
قديم منذ /27-04-2017, 05:55 AM   #10

طالب جديد

Malak ammar غير متواجد حالياً

 

مواضيعي | ردودي

 رقم العضوية : 7562
 تاريخ الإنتساب : Dec 2013
 المشاركات : 13
 الجنس : أنثى
 مستوى التقييم : Malak ammar is on a distinguished road
النقاط : 0

شكراً: 0
تم شكره مرة واحدة في مشاركة واحدة
افتراضي


third and fourth questiones








  رد مع اقتباس
إضافة رد

مواقع النشر (المفضلة)

أدوات الموضوع
انواع عرض الموضوع

تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة
Trackbacks are متاحة
Pingbacks are متاحة
Refbacks are متاحة