תרגול 7 רשימות משורשרות, רקורסיית

Size: px
Start display at page:

Download "תרגול 7 רשימות משורשרות, רקורסיית"

Transcription

1 מבוא למדעי המחשב 2018 תרגול 7 רשימות משורשרות, רקורסיית זנב 1

2 ראינו בהרצאה רשימות משורשרות רקורסיית זנב 2

3 בתרגול היום רשימות משורשרות עוד שיטות מחלקה רקורסיית זנב היפוך מחרוזות, חיפוש בינארי 3

4 רשימות משורשרות 4

5 תזכורת המחלקות LinkedList, Link public class LinkedList { private static class Link { private Link first; public LinkedList () { first = null; public boolean isempty(){ return first == null; public void addfirst(object element) { if (isempty()) first = new Link(element) else first = new Link(element, first); public void remove(object toremove){ public String tostring(){ public Object get(int index){ public boolean contains(object element){ public Object remove(object element){ 5 private Object data; private Link next; public Link (Object data) { this(data, null); public Link (Object data, Link next) { this.data = data; this.next = next; public object getdata() { return data; public Link getnext() { return next; public Link setnext(link next) { this.next = next; public String tostring(){ return data.tostring; // end of Link class // end of LinkedList class

6 שיטות נוספות נוסיף את השיטות הבאות במחלקה :LinkedList element) indexof(object החזרת האינדקס בו נמצא המופע הראשון של element או 1- אם הוא לא נמצא ברשימה. index החלפת האיבר במקום ה- set(int index, Object element) עם.element element) add(int index, Object הכנסת איבר למקום ה- index תוך הזזה ימינה של כל אברי הרשימה החל מ- index. element) add(object הוספת איבר לסוף הרשימה. 6

7 שיטות נוספות indexof public class LinkedList { // returns the index of the first occurrence of the specified element in this list, or -1 if // this list does not contain the element. public int indexof(object element){ if(element == null) throw new NullPointerException(); int index = 0; for(link curr = first; curr!= null ; curr = curr.getnext()){ if( curr.getdata().equals(element) ) return index; else return -1; index = index + 1; null indexof(5) is 1 7

8 שיטות נוספות set public class LinkedList { // replaces the element at the specified position in this list with the specified element // throws NullPointerException - if the specified element is null // throws IndexOutOfBoundsException if the index is out of range (index < 0 index >= size()) public Object set(int index, Object element){ if(index < 0 index >= size()) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size()); if(element == null) throw new NullPointerException(); Link current = first; while (index > 0) { index = index - 1; current = current.getnext(); Object prev = current.getdata(); current.setdata(element); return prev; null After set(3, 1) null Returns 5 8

9 שיטות נוספות add public class LinkedList { // inserts the specified element at the specified position in this list // throws NullPointerException - if the specified element is null // throws IndexOutOfBoundsException if the index is out of range (index < 0 index >= size()) public void add(int index, Object element) { if(index < 0 index > size()) throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size()); if(element == null) throw new NullPointerException(); if(index == 0) addfirst(element); else { Link prev = null ; Link curr = first ; for(int i = 0; i < index; i = i + 1) { prev = curr; curr = curr.getnext(); Link toadd = new Link(element, curr); prev.setnext(toadd); null After add(3, 1) null 9

10 שיטות נוספות add public class LinkedList { // appends the specified element to the end of this list // throws NullPointerException - if the specified element is null public boolean add(object element) { if(element == null) throw new NullPointerException(); if(isempty()) addfirst(element); else { Link current = first; while(current.getnext()!= null){ current = current.getnext(); { current.setnext(new Link(element)); return true; null After add(2) null 10

11 רשימה כמבנה רקורסיבי כאמור, מעצם הגדרתה של רשימה, ניתן לראות את טבעה הרקורסיבי. הגדרת חוליה ברשימה מכילה מצביע מאותו טיפוס. נראה כיצד ניתן לנצל תכונה זאת. 11

12 השיטה add במחלקות LinkedList, Link public class LinkedList { private Link first; public LinkedList () { private static class Link { private Object data; private Link next; public Link (Object data) { public Link (Object data, Link next) { public void add(object e) { if (isempty()) addfirst(e); else first.add(e); public void add(object e) { If (next == null) next = new Link(e); else next.add(e); // end of Link class // end of LinkedList class 12

13 השיטה print במחלקות LinkedList, Link public class LinkedList { private Link first; public LinkedList () { private static class Link { private Object data; private Link next; public Link (Object data) { public Link (Object data, Link next) { public void print() { if (first!= null) first.print(); public void print() { System.out.println(data.toString()); if (next!= null) next.print(); // end of Link class // end of LinkedList class 13

14 השיטה printbackwards במחלקות LinkedList, Link public class LinkedList { private Link first; public LinkedList () { private static class Link { private Object data; private Link next; public Link (Object data) { public Link (Object data, Link next) { public void printbackwards() { if (first!= null) first.printbackwards(); public void printbackwards() { if (next!= null) next.printbackwards(); System.out.println(data.toString()); // end of Link class // end of LinkedList class 14

15 אתגר הוסיפו את השיטות הבאות באופן רקורסיבי: element) indexof(object החזרת האינדקס בו נמצא המופע הראשון של element או 1- אם הוא לא נמצא ברשימה. index החלפת האיבר במקום ה- set(int index, Object element) עם.element element) add(int index, Object הכנסת איבר למקום ה- index תוך הזזה ימינה של כל אברי הרשימה החל מ- index. 15

16 הפסקה 16

17 רקורסיית זנב 17

18 רקורסיית זנב רקורסיית זנב היא מקרה מיוחד של רקורסיה, בו הקריאה הרקורסיבית הינה הפעולה האחרונה שהפונקציה הרקורסיבית מבצעת )פרט להשמה ואז.)return 18

19 היפוך מחרוזות נרצה לכתוב פונקציה המקבלת מחרוזת str ומחזירה מחרוזת הפוכה. ראינו בהרצאה פונקציה הפותרת את הבעיה בלי רקורסיית זנב. 19

20 reverse from class // gets a string and reverses it public static String reverse(string str){ if(str == null) { throw new NullPointerException(); { String output; if(str.length() == 0) return str; else return reverse(str.substring(1)) + str.charat(0); { מדוע הפונקציה איננה רקורסיית זנב? מה עלינו לעשות בשביל להפוך את הפונקציה לרקורסיית זנב? 20

21 Reverse - tail recursion // gets a string and flips it public static String reversetail(string str) { if (str == null){ throw new NullPointerException(); return reversetail(str, ""); { // flips str and and concatenate acc from the right public static String reversetail(string str, String acc) { if (str.length() == 0) { return acc; else { return reversetail(str.substring(1), str.charat(0) + acc); { { 21

22 חיפוש בינארי רקורסיבי בהינתן מערך ממוין של מספרים שלמים ומפתח,key במערך. כיצד נעשה זאת באופן רקורסיבי? נרצה לדעת היכן מיקומו ראשית ניגש לאמצע המערך ונבדוק האם key מצוי שם. אם כן, נחזיר את מיקומו. אחרת, אם ערכו של המיקום האמצעי גדול מ-,key נחפש בחציו הימני של המערך באופן רקורסיבי. אחרת, נחפש בחציו השמאלי של המערך באופן רקורסיבי. מתי נעצור? 22

23 חיפוש בינארי רקורסיבי key = output = 5 mid = 4 mid = 5 mid = 7 // returns the index of element key within a sorted array or -1 if key // doesn t appears in arr. public static int recsearch(int key, int[] arr) { if (arr==null arr.length==0 (key<arr[0] key>arr[arr.length])) return -1; return recsearch(key, arr, 0, arr.length-1); 24

24 חיפוש בינארי רקורסיבי // returns the index of element key within a sorted array in the // index interval [from, till], or -1 if key doesn t appears in arr. public static int recsearch(int key, int[] arr, int from, int till) { if(from <= till) { int mid = (from + till)/2; if(key < arr[mid]) return recsearch(key, arr, from, mid-1); else if(key > arr[mid]) return recsearch(key, arr, mid+1, till); else return mid; return -1; 25

25 מיון הכנסה רקורסיבי למדנו בכתה איך לבצע מיון הכנסה. ראינו כי המיון מסתמך על הטענה כי כל אברי המערך עד למקום מסוים ממוינים, נסמן מקום זה ב- i. אלגוריתם המיון משמר טענה זו לאורך ריצתו ומנסה להכניס לחלק הממוין של המערך את האיבר המופיע מיקום אחד אחרי המיקום המסוים i, וכאשר מגיע לסוף המערך, מובטח כי המערך ממוין. 26

26 מיון הכנסה רקורסיבי רעיון האלגוריתם: בהינתן מערך ואינדקס )שעד אליו המערך ממוין(, אם האינדקס הוא סוף המערך, חזור. אחרת: הכנס למערך את הערך הנמצא באינדקס כך שישמר ממוין. מיין את שאר אברי המערך באופן רקורסיבי. 27

27 // sorts the given array public static void insertionsort(int[] arr) { insertionsort(arr, 0); // begins from index zero מיון הכנסה רקורסיבי // invariant: arr is sorted till indextoinsert. // inserts arr[indextoinsert] into its right position within the // sorted part of arr, and sorts the rest of the array. public static void insertionsort(int[] arr, int indextoinsert) { if(indextoinsert >= arr.length) return; insert(arr, indextoinsert); // insert function we ve seen in ps 3 insertionsort(arr, indextoinsert + 1); 28

28 סיכום ומשימות תרגלנו רשימות משורשרות רקורסיית זנב משימות עבודת בית 3 הגישו בסיום כל משימה! Quiz 6 29

מבוא למדעי המחשב 2018 תרגול 7

מבוא למדעי המחשב 2018 תרגול 7 מבוא למדעי המחשב 2018 תרגול 7 רשימות משורשרות, רקורסיית זנב 1 ראינו בהרצאה רשימות משורשרות רקורסיית זנב 2 בתרגול היום רשימות משורשרות עוד שיטות מחלקה רקורסיית זנב היפוך מחרוזות, חיפוש בינארי 3 רשימות משורשרות

More information

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator מבוא למדעי המחשב 2017 תרגול 8 רשימה משורשרת כללית, Comparator בתרגול היום. LinkedList בניית ההכללה מ- LinkIntList תרגול המבנה ושימושיו ממשקים: Comparator Sorted Linked List ל- LinkedList ע"י שימוש ב- Comparator

More information

תזכורת: עץבינארי מבוא למדעי המחשב הרצאה 24: עצי חיפוש בינאריים

תזכורת: עץבינארי מבוא למדעי המחשב הרצאה 24: עצי חיפוש בינאריים מבוא למדעי המחשב הרצאה 2: עצי חיפוש בינאריים תזכורת: עץבינארי בנוסףלרשימהמקושרת ומערך, הצגנומבנהנתונים קונקרטיחדש עץבינארי עץבינארימורכבמ: שורש תת-עץשמאלי תת-עץימני A B C D E F G 2 תזכורת: שורש ותתי-עצים

More information

תרגול 6 רקורסיה ותכנות מונחה עצמים

תרגול 6 רקורסיה ותכנות מונחה עצמים מבוא למדעי המחשב 2017 תרגול 6 רקורסיה ותכנות מונחה עצמים מבוא למדעי המחשב 1 ראינו בהרצאה רקורסיה תכנות מונחה עצמים: מחלקה ואובייקט שדות, בנאים ושיטות מימוש מערך דינאמי של ראשוניים בתרגול היום רקורסיה הדפסת

More information

ת ונכת סרוק תורשוקמ תומישר :יעישת רועיש 1

ת ונכת סרוק תורשוקמ תומישר :יעישת רועיש 1 קורס תכנות שיעור תשיעי: רשימות מקושרות 1 הקצאה דינאמית של מערכים דו-ממדיים )לפחות( שלוש גישות אפשריות:.1 מערך של מערכים מצביעים לתוך מערך "גדול".2 3. מצביע יחיד למערך גדול 2 The Interface 3 (Simple) Usage

More information

קורס תכנות רשימה מקושרת דוגמה: חיפוש מעבר על רשימה דוגמא: שחרור רשימה מקושרת דוגמא: הוספת אברים שלא בהתחלה

קורס תכנות רשימה מקושרת דוגמה: חיפוש מעבר על רשימה דוגמא: שחרור רשימה מקושרת דוגמא: הוספת אברים שלא בהתחלה רשימה מקושרת רשימה היא אוסף סדור של ערכים פעולות רשימה לעומת מערך קורס תכנות שיעור עשירי: מיונים, חיפושים, קצת ניתוח זמני ריצה, קצת תיקון טעויות ועוד על רשימות 3 5 7 9 typedef struct node int data; struct

More information

תור שימושים בעולם התוכנה

תור שימושים בעולם התוכנה מבוא למדעי המחשב הרצאה : Queue, Iterator & Iterable תור מבנה נתונים אבסטרקטי תור שימושים בעולם התוכנה השימושים של תורים בעולם התוכנה מזכירים מאוד תורים במציאות: )VoIP( )YouTube( מקלדת שידור סרט באינטרנט

More information

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 מערכים שעור מס. 4 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 למה מערכים? ברצוננו לאחסן בתוכנית ציוני בחינה כדי לחשב את ממוצע הציונים וסטיית התקן. נניח ש 30 סטודנטים לקחו

More information

מבוא לתכנות ב- JAVA תרגול 7

מבוא לתכנות ב- JAVA תרגול 7 מבוא לתכנות ב- JAVA תרגול 7 רקורסיה - הקדמה הגדרה רקורסיבית: חדר הוא מסודר אם צד שמאל שלו מסודר שלו מסודר. וצד ימין שיטת פתרון רקורסיבית: פתרון מופעים פשוטים יותר של בעיה בכדי לפתור את הבעיה המקורית רקורסיה

More information

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num)

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num) 1 תבנית צבירה תבניות אלגוריתמיות לפעולות רקורסיביות תבנית צבירה לסדרת ערכים: סכום (סדרת ערכים) החזר את ערך הקצה + סכום (סדרת הערכים ללא ערך הקצה) דוגמא: פעולה המחזירה את סכום הספרות שבמספר שלם לא שלילי

More information

שאלה 1 מהו הפלט של התוכנית הבאה:

שאלה 1 מהו הפלט של התוכנית הבאה: תרגול חזרה שאלה 1 מהו הפלט של התוכנית הבאה: public sttic int wht(int n) { int i; int sum=0; if(n == 0) return 1; for (i=0; i

More information

רזח יליגרתו םי יראני ב ם

רזח יליגרתו םי יראני ב ם מבוא למדעי המחשב עצים בינאריים ותרגילי חזרה תרגול 13: עצים בינאריים - הגדרה הגדרה: עץ בינארי הוא עץ ריק )בלי צמתים( או עץ המורכב משורש ושני תתי-עצים, הוא עץ בינארי. ימני ושמאלי, שכל אחד מהם שאלה עץ בינארי

More information

Linked Lists. Linked List Nodes. Walls and Mirrors Chapter 5 10/25/12. A linked list is a collection of Nodes: item next -3.

Linked Lists. Linked List Nodes. Walls and Mirrors Chapter 5 10/25/12. A linked list is a collection of Nodes: item next -3. Linked Lists Walls and Mirrors Chapter 5 Linked List Nodes public class Node { private int item; private Node next; public Node(int item) { this(item,null); public Node(int item, Node next) { setitem(item);

More information

מבוא לתכנות ב- JAVA תרגול 6

מבוא לתכנות ב- JAVA תרגול 6 מבוא לתכנות ב- JAVA תרגול 6 מה בתרגול )methods( פונקציות/שיטות ב- Java הגדרת פונקציה קריאה/הפעלה העברת ארגומנטים ערכי החזרה מבוא לפונקציות- שימוש חוזר בקוד נניח שבמהלך תוכנית נדרשתם לחשב את הסכום של המספרים

More information

Exams questions examples

Exams questions examples Exams questions examples 1 Exam example 1. y - x what נק' ( לפניך הפעולה הרקורסיבית מקבלת כפרמטרים שני מספרים שלמים ו 10 )? מה יהיה הפלט כתוצאה מזימון הפעולה what public static int what(int x, int y) if(x

More information

Linked Lists. Chapter 12.3 in Savitch

Linked Lists. Chapter 12.3 in Savitch Linked Lists Chapter 12.3 in Savitch Preliminaries n Arrays are not always the optimal data structure: q An array has fixed size needs to be copied to expand its capacity q Adding in the middle of an array

More information

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12

CS 151. Linked Lists, Recursively Implemented. Wednesday, October 3, 12 CS 151 Linked Lists, Recursively Implemented 1 2 Linked Lists, Revisited Recall that a linked list is a structure that represents a sequence of elements that are stored non-contiguously in memory. We can

More information

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization מערכים תוכנה 1 Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 תרגול 2: מערכים

More information

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays מערכים Array: A fixed-length data structure for storing multiple values of the same type תוכנה 1 Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds: 1 3 5 7 9 11 13 15 odds.length

More information

תוכנה 1 3 תרגול מס' מערכים ומבני בקרה

תוכנה 1 3 תרגול מס' מערכים ומבני בקרה תוכנה 1 3 תרגול מס' מערכים ומבני בקרה מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5 6 7 odds:

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 >>g = [89 91 80 98]; >>p

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 23427 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 203 Based on slides of Dr. Eran Eden, Weizmann 2008 ביטויים לוגיים דוגמא: תקינות

More information

מבני נתונים תכנות מונחה עצמים מבני נתונים. מחלקות אבסטרקטיות חבילות packages סיכום הרשאות גישה wrappers ADT מערך דינמי מחסנית

מבני נתונים תכנות מונחה עצמים מבני נתונים. מחלקות אבסטרקטיות חבילות packages סיכום הרשאות גישה wrappers ADT מערך דינמי מחסנית מבני נתונים 1 תכנות מונחה עצמים מחלקות אבסטרקטיות חבילות packages סיכום הרשאות גישה wrappers מבני נתונים ADT מערך דינמי מחסנית 2 1 מבני נתונים תור - Queue Iterators רשימות מקושרות "רגילות" 3 מבנה נתונים

More information

מבוא למדעי המחשב תרגול 12 מחסנית )Stack( memoization

מבוא למדעי המחשב תרגול 12 מחסנית )Stack( memoization מבוא למדעי המחשב 2017 תרגול 12 מחסנית )Stack( memoization בתרגול היום מחסנית בדיקת איזון סוגריים בביטוי אריתמטי משולש Pascal לא רקורסיבי memoization דוגמאות שימוש: בעיית העודף תזכורת: מחסנית :)stack( מבנה

More information

תרגול 3 מערכים ופונקציות

תרגול 3 מערכים ופונקציות מבוא למדעי המחשב 2017 תרגול 3 מערכים ופונקציות מערכים מאפשרים עבודה עם מקבצים של נתונים פונקציות מאפשרות אבסטרקציה והאחדה של הקוד ראינו בהרצאה מערכים הצהרה, אתחול, גישה לאיברים במערך יצוג בזיכרון ובטבלת

More information

מבוא לתכנות ב- JAVA מעבדה 4

מבוא לתכנות ב- JAVA מעבדה 4 מבוא לתכנות ב- JAVA מעבדה 4 מה בתרגול מערכים מחרוזות מערך חד מימדי מערך הוא מבנה המחזיק סדרה של איברים מאותו טיפוס גודל המערך הוא קבוע )נקבע בעת יצירת המערך( הגישה לכל איבר היא באמצעות אינדקס למה לי מערך?

More information

Week 4, Wednesday (Spring 2015). Dr. Yoder. Sec 051. Page 1 of 5

Week 4, Wednesday (Spring 2015). Dr. Yoder. Sec 051. Page 1 of 5 CS2852 Exam 1 Name: No note-sheets, calculators, or other study aids on this exam. Write your initials at the top of each page except this one. Read through the whole exam before you get started. Have

More information

Linked List. ape hen dog cat fox. tail. head. count 5

Linked List. ape hen dog cat fox. tail. head. count 5 Linked Lists Linked List L tail head count 5 ape hen dog cat fox Collection of nodes with a linear ordering Has pointers to the beginning and end nodes Each node points to the next node Final node points

More information

תוכנה 1 תרגול 2: מערכים ומבני בקרה

תוכנה 1 תרגול 2: מערכים ומבני בקרה תוכנה 1 תרגול 2: מערכים ומבני בקרה 2 Useful Eclipse Shortcuts Ctrl+1 quick fix for errors, or small refactoring suggestions Ctrl+SPACE code content assist (auto-completion) Auto completion for main create

More information

קורס תכנות בשיעור הקודם למדנו על רקורסיה שיעור שישי: מערכים פונקציה רקורסיבית שאלה חישוב נוסחאות רקורסיביות בשפת C

קורס תכנות בשיעור הקודם למדנו על רקורסיה שיעור שישי: מערכים פונקציה רקורסיבית שאלה חישוב נוסחאות רקורסיביות בשפת C בשיעור הקודם למדנו על רקורסיה פתרנו את בעיית מגדלי הנוי בעזרת רקורסיה כלומר בעזרת פונקציה שקוראת לעצמה. רקורסיה מאפשרת לנו לפתור בעיה "גדולה" בעזרת פתרון של בעיות "קטנות" המרכיבות אותה. קורס תכנות שיעור

More information

Practical Session No. 14 Topological sort,amortized Analysis

Practical Session No. 14 Topological sort,amortized Analysis Practical Session No. 14 Topological sort,amortized Analysis Topological- Sort Topological sort Ordering of vertices in a directed acyclic graph (DAG) G=(V,E) such that if there is a path from v to u in

More information

עצים. מבני נתונים Iterators רשימות מקושרות עצים "רגילות" רקורסיביות

עצים. מבני נתונים Iterators רשימות מקושרות עצים רגילות רקורסיביות עצים 1 מבני נתונים Iterators רשימות מקושרות "רגילות" רקורסיביות עצים 2 1 עצים בינאריים סריקות על עצים עצי חיפוש מימוש Iterators לסריקה 3 עץ בינארי הינו מבנה נתונים המייצג עץ מושרש )כלומר עם שורש( עץ בינארי

More information

הנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת

הנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices (start

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 9: Sorting, Searching and Time Complexity Analysis Autumn 2011-12 1 Lecture 8: Highlights Design a recursive algorithm by 1. Solving big instances using the

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Lecture 9: Sorting, Searching and Time Complexity Analysis Autumn 2011-12 1 Lecture 8: Highlights Design a recursive algorithm by 1. Solving big instances using the

More information

הנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת

הנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת תוכנה 1 תרגול 2: מערכים, לולאות והתמודדות עם שגיאות מערכים מערכים Array: A fixed-length data structure for storing multiple values of the same type Example from last week: An array of odd numbers: Indices

More information

מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development(

מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development( מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development( תוכנה 1 תרגול 8 String Immutability Strings are constants String s = " Tea "; s = s.trim(); s = s.replace('t', 'S'); s 1 2 3 " Tea " "Tea" "Sea"

More information

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes תוכנה 1 תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes class Outer { static class NestedButNotInner {... class Inner {... מחלקות מקוננות NESTED CLASSES 2 מחלקה מקוננת Class) )Nested

More information

מבוא למדעי המחשב תרגול 13: עצים בינאריים

מבוא למדעי המחשב תרגול 13: עצים בינאריים מבוא למדעי המחשב תרגול 13: עצים בינאריים עצים בינאריים - הגדרה הגדרה: עץ בינארי הוא עץ ריק (בלי צמתים) או עץ המורכב משורש ושני תתי-עצים, הוא עץ בינארי. ימני ושמאלי, שכל אחד מהם תרגיל 1 עץ בינארי מסודר

More information

חומר עזר לבחינה במבוא למדעי המחשב // Indicates whether some other object is "equal to" // this one. boolean equals(object other)

חומר עזר לבחינה במבוא למדעי המחשב // Indicates whether some other object is equal to // this one. boolean equals(object other) חומר עזר לבחינה במבוא למדעי המחשב 202-1-1011 שיטות במחלקה Object // Indicates whether some other object is "equal to" // this one. boolean equals(object other) // Returns a string representation of the

More information

מבוא לתכנות בשפת C. Tzachi (Isaac) Rosen

מבוא לתכנות בשפת C. Tzachi (Isaac) Rosen מבוא לתכנות בשפת C מצביעים והקצאה דינאמית כתובות של משתנים לכל משתנה כתובת של המקום שלו בזיכרון כבר ראינו: שם של מערך הוא למעשה הכתובת של התא הראשון )באינדקס 0( של המערך להזכירכם: תא של מערך הינו משתנה

More information

תרגול 3 מערכים ופונקציות

תרגול 3 מערכים ופונקציות מבוא למדעי המחשב 2018 תרגול 3 מערכים ופונקציות מערכים מאפשרים עבודה עם מקבצים של נתונים פונקציות מאפשרות אבסטרקציה והאחדה של הקוד ראינו בהרצאה מערכים הצהרה, אתחול, גישה לאיברים במערך יצוג בזיכרון ובטבלת

More information

LinkedList Implementation Mini-project intro

LinkedList Implementation Mini-project intro LinkedList Implementation Mini-project intro Turn in your written problems Mini-project Partner Survey: Do it by 4:00 today Reminder: Exam #2 is this Thursday In order to reduce time pressure, you optionally

More information

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. Just an Illusion? List Interface (review) Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 13 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

תוכנה 1 טיפוסי השפה טיפוסים לא פרימיטיביים הטיפוסים הפרימיטיביים מחרוזות המרה למספרים תרגול 2: טיפוסי שפה, מחרוזות, מערכים ושגיאות

תוכנה 1 טיפוסי השפה טיפוסים לא פרימיטיביים הטיפוסים הפרימיטיביים מחרוזות המרה למספרים תרגול 2: טיפוסי שפה, מחרוזות, מערכים ושגיאות טיפוסי השפה תוכנה 1 תרגול 2: טיפוסי שפה, מחרוזות, מערכים ושגיאות טיפוסים יסודיים (פרימיטיביים): 8 טיפוסים מוגדרים בשפה שמיועדים להכיל ערכים פשוטים: מספרים שלמים: byte, short, int, long מספרים ממשיים: float,

More information

Algorithms. Intro2CS week 5

Algorithms. Intro2CS week 5 Algorithms Intro2CS week 5 1 Computational problems A computational problem specifies an inputoutput relationship What does the input look like? What should the output be for each input? Example: Input:

More information

תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות

תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות מערכים Array: A fixed-length data structure for storing multiple values of the same type Example: An array of odd numbers: Indices (start from 0) 0 1 2 3 4 5

More information

מבוא למדעי המחשב תרגול 5: לולאות ומערכים

מבוא למדעי המחשב תרגול 5: לולאות ומערכים מבוא למדעי המחשב תרגול 5: לולאות ומערכים תוכנייה לולאת while, do while, for מערכים מערכים דו ממדיים 2 לולאות 3 תזכורת: לולאת while גוף הלולאה מתבצע שוב ושוב כל עוד התנאי מתקיים int number; scanf( %d, &number);

More information

תרגול 4 פונקציות. מבנה של פונקציה: public static <return value type> <function name> (<arg1 type> <arg1>, <arg2 type> <arg2>, ) { <function body> }

תרגול 4 פונקציות. מבנה של פונקציה: public static <return value type> <function name> (<arg1 type> <arg1>, <arg2 type> <arg2>, ) { <function body> } נושאי התרגול: מה הן פונקציות הגדרת פונקציה,קריאה לפונקציה העברת ארגומנטים,החזרת ערך או void העברת משתנים פרימיטיביים ומערכים לפונקציה העמסה של פונקציות תרגול 4 פונקציות מוטיבציה לעיתים,אנו נזקקים לבצע

More information

Computer Programming A תרגול 9

Computer Programming A תרגול 9 Computer Programming A תרגול 9 1 מטרת התרגול הקצאת זיכרון מבנים רשימות דינאמית ניהול הזיכרון בתוכנית עד כה כל המשתנים שראינו היו לוקאליים. משך הקיום של משתנים מקומיים הוא הזמן אשר הפונקציה בה הם נמצאים

More information

Implementing a List in Java. CSE 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List.

Implementing a List in Java. CSE 143 Java. List Interface (review) Just an Illusion? Using an Array to Implement a List. Implementing a List in Java CSE 143 Java List Implementation Using Arrays Reading: Ch. 22 Two implementation approaches are most commonly used for simple lists: Arrays Linked list Java Interface List concrete

More information

פתרון מוצע לבחינה בשפת C של מה"ט מועד אביב תשע"ז, פברואר 2017 מחבר: מר עסאקלה שאדי, מכללת אורט בראודה

פתרון מוצע לבחינה בשפת C של מהט מועד אביב תשעז, פברואר 2017 מחבר: מר עסאקלה שאדי, מכללת אורט בראודה פתרון מוצע לבחינה בשפת C של מה"ט מועד אביב תשע"ז, פברואר 2017 מחבר: מר עסאקלה שאדי, מכללת אורט בראודה שאלה מספר 1 נתונה התכנית הבאה בשפת C: #include #define SUM_OF_3(x,y,z) x+y+z #define AVRG_OF_3(x,y,z)

More information

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 משתנים שעור מס. 2 דרור טובי דר' כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1 תפקיד המשתנים הצהרה על משתנה השמת ערך במשתנה int a, b, c; a = 1234; b = 99; c = a + b; משתנים מאפשרים לנו לשמור

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 בחינה באופק! הבחינה תכלול את כל הנושאים שכיסינו במהלך הסמסטר: כל ההרצאות כל תרגולים כל תרגילי בית חומר סגור שאלות אמריקאיות 2 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים

More information

מבוא לתכנות ב- JAVA תרגול 5. Ipc161- practical session 5

מבוא לתכנות ב- JAVA תרגול 5. Ipc161- practical session 5 מבוא לתכנות ב- JAVA תרגול 5 Ipc161- practical session 5 מה בתרגול מערכים דו ממדיים )methods( פונקציות/שיטות ב- Java הגדרת פונקציה קריאה/הפעלה העברת ארגומנטים ערכי החזרה מערך דו ממדי מערך של מערכים חד ממדיים

More information

הנכות 1 םוכיס לוגרת 14 1

הנכות 1 םוכיס לוגרת 14 1 תוכנה 1 סיכום תרגול 14 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers

More information

מבוא למדעי המחשב תרגול 10 Comparator, Comparable, Binary Trees

מבוא למדעי המחשב תרגול 10 Comparator, Comparable, Binary Trees מבוא למדעי המחשב 2018 תרגול 10 Comparator, Comparable, Binary Trees ראינו בהרצאה ממשקים Iterator Comparable Comparator עצים בינאריים BinaryNode,BinaryTree סריקות בתרגול היום ממשקים Comparable Comparator

More information

1. ArrayList and Iterator in Java

1. ArrayList and Iterator in Java 1. ArrayList and Iterator in Java Inserting elements between existing elements of an ArrayList or Vector is an inefficient operation- all element after the new one must be moved out of the way which could

More information

רשימות דילוגים Skip Lists

רשימות דילוגים Skip Lists Lecture6 of Geiger & Itai s slide brochure www.cs.technion.ac.il/~dang/courseds רשימות דילוגים Skip Lists Skip lists: A probabilistic Alternative to Balanced Trees, William Pugh, Communications of the

More information

Review: List Implementations. CSE 143 Java. Links. A Different Strategy: Lists via Links. Linked Links. CSE143 Au List

Review: List Implementations. CSE 143 Java. Links. A Different Strategy: Lists via Links. Linked Links. CSE143 Au List Review: Implementations CSE 143 Java ed s Reading: Ch. 23 The external interface is already defined Implementation goal: implement methods efficiently Array approach: use an array with extra space internally

More information

Arrays. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Arrays. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html 1 Arrays Arrays in Java an array is a container object that holds a fixed number of values of a single type the length of an array is established when the array is created 2 https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

More information

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions מבוא לתיכנות עם MATLAB 234127 Lecture 5: Boolean logic and Boolean expressions Written by Prof. Reuven Bar-Yehuda, Technion 2013 Based on slides of Dr. Eran Eden, Weizmann 2008 1 motivation Proper academic

More information

קורס תכנות שיעור שישי: מחרוזות, מצביעים

קורס תכנות שיעור שישי: מחרוזות, מצביעים קורס תכנות שיעור שישי: מחרוזות, מצביעים מערכים אוסף סדור של משתנים מאותו סוג המשתנים נמצאים ברצף בזיכרון העברת מערך לפונקציה Define רקורסיה במערך מערכים דו מימדיים 2 מחרוזות מהי מחרוזת? רצף של תוים ייצוג

More information

מבוא לתכנות ב- JAVA מעבדה 2

מבוא לתכנות ב- JAVA מעבדה 2 מבוא לתכנות ב- JAVA מעבדה 2 מה בתרגול טיפוסים פרימיטיביים המרות טיפוסים אופרטורים יחסיים ולוגיים משפט if-else בתרגול הקודם טיפוסים פרימיטביים לייצוג מספרים שלמים וממשיים ואופרטורים לפעולות בין מספרים.1

More information

Engineering Programming A

Engineering Programming A Engineering Programming A תרגול 5 25.11.2012 מערכים חד-מימדיים )תזכורת( לדוגמא: מערך בשם Arr בגודל 8 שאיבריו מטיפוס int 3 7 5 6 8 1 23 16 0 1 2 3 4 5 6 7 ב - arr[0] ב יושב ערך שהוא המספר השלם 3 arr[1]

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 בחינה באופק! הבחינה תכלול את כל הנושאים שכיסינו במהלך הסמסטר: כל ההרצאות כל תרגולים כל תרגילי בית חומר סגור שאלות אמריקאיות 2 קצת על מנשקים מנשק יכול להרחיב שירותים במנשק הם תמיד

More information

Introduction to Computer Science II CS S-20 Linked Lists III

Introduction to Computer Science II CS S-20 Linked Lists III Introduction to Computer Science II CS112-2012S-20 Linked Lists III David Galles Department of Computer Science University of San Francisco 20-0: Linked List Previous Practical Example: removeat(int index)

More information

Introduction to Computer Science II CS S-18 Linked Lists

Introduction to Computer Science II CS S-18 Linked Lists Introduction to Computer Science II CS112-2012S-18 Linked Lists David Galles Department of Computer Science University of San Francisco 18-0: Linked Lists Linked List node Data Pointer to the next element

More information

עמוד 1 (תאריך ( âùéä ער äìàù בכל השאלות ניתן להניח שהקלט תקין. 100 íåëñ חורף :

עמוד 1 (תאריך ( âùéä ער äìàù בכל השאלות ניתן להניח שהקלט תקין. 100 íåëñ חורף : עמוד 1 מבוא למדעי המחשב מ' 234114 מבוא למדעי המחשב ח' 234117 מבחן מועד א', סמסטר חורף תשס"ב (תאריך ( 29.1.03 שם משפחה שם פרטי מס' סטודנט âùéä ער äìàù 15 1 15 2 16 3 18 4 16 5 20 6 100 íåëñ חומר עזר: אין

More information

Practical Session - Heap

Practical Session - Heap Practical Session - Heap Heap Heap Maximum-Heap Minimum-Heap Heap-Array A binary heap can be considered as a complete binary tree, (the last level is full from the left to a certain point). For each node

More information

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion Prelim 1 CS 2110, October 1, 2015, 5:30 PM 0 1 2 3 4 5 Total Question Name True Short Testing Strings Recursion False Answer Max 1 20 36 16 15 12 100 Score Grader The exam is closed book and closed notes.

More information

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 STATIC VS. DYNAMIC BINDING 3 Static versus Dynamic Binding public class Account

More information

COMP200 GENERICS. OOP using Java, from slides by Shayan Javed

COMP200 GENERICS. OOP using Java, from slides by Shayan Javed 1 1 COMP200 GENERICS OOP using Java, from slides by Shayan Javed 2 ArrayList and Java Generics 3 Collection A container object that groups multiple objects 4 Collection A container object that groups multiple

More information

לוח מבחנים מבוסס על דף עבודה ממקור לא ידוע. פעולה בונה היוצרת לוח מבחנים )ריק(. void Add (Test t)

לוח מבחנים מבוסס על דף עבודה ממקור לא ידוע. פעולה בונה היוצרת לוח מבחנים )ריק(. void Add (Test t) 1 לוח מבחנים מבוסס על דף עבודה ממקור לא ידוע 1. המחלקה מבחן Test מגדירה מבחן לפי תרשים uml הבא: להלן ממשק המחלקה Test תיאור הפעולה פעולה בונה היוצרת מבחן במקצוע subject ובתאריך date פעולה המחזירה מקצוע

More information

הנכות 1 םוכיס לוגרת 13 1

הנכות 1 םוכיס לוגרת 13 1 תוכנה 1 סיכום תרגול 13 1 קצת על מנשקים מנשק יכול להרחיב יותר ממנשק אחד שירותים במנשק הם תמיד מופשטים וציבוריים public interface MyInterface { public abstract int foo1(int i); int foo2(int i); The modifiers

More information

פתרון מוצע לבחינת מה"ט ב_שפת c מועד אביב תשע"ח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות

פתרון מוצע לבחינת מהט ב_שפת c מועד אביב תשעח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות פתרון מוצע לבחינת מה"ט ב_שפת c מועד אביב תשע"ח, פברואר 8102 מחבר: מר שייקה בילו, מכללת אורט רחובות שאלה מספר 1 התוכנית מגדירה חמישה משתנים שלמים: השלושה הראשונים הם שלושה מצביעים - *s *t,i. j ושלושה נוספים

More information

תוכנה 1 סמסטר א' תשע"א

תוכנה 1 סמסטר א' תשעא General Tips on Programming תוכנה 1 סמסטר א' תשע"א תרגול מס' 6 מנשקים, דיאגרמות וביטים * רובי בוים ומתי שמרת Write your code modularly top-down approach Compile + test functionality on the fly Start with

More information

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1

Topic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1 Topic #9: Collections CSE 413, Autumn 2004 Programming Languages http://www.cs.washington.edu/education/courses/413/04au/ If S is a subtype of T, what is S permitted to do with the methods of T? Typing

More information

מבוא למדעי המחשב תירגול 3:

מבוא למדעי המחשב תירגול 3: מבוא למדעי המחשב תירגול 3: לולאות, קלט, וטיפוסים תוכנייה לולאת while קלט טיפוסי משתנים המרת טיפוסים טיפוס char מבוא למדעי המחשב מ' - תירגול 3 2 לולאת while מבוא למדעי המחשב מ' - תירגול 3 3 לולאת while

More information

דף הדרכה ליצירת שרת/ לקוח עם GUI

דף הדרכה ליצירת שרת/ לקוח עם GUI דף הדרכה ליצירת שרת/ לקוח עם GUI בשיעורים הקודמים למדנו כיצד ליצור שרת לקוח פשוט, ויצירת טופס המכיל פקדים כלומר יצירת GUI למשתמש, בשיעור זה נרצה להראות את הדרך לשילוב בין השניים כלומר ליצור לקוח client

More information

תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב

תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב Today Static vs. Dynamic binding Equals / hashcode String Immutability (maybe) 2 Static versus run-time

More information

מבוא למדעי המחשב תרגול 10 הממשקים Iterator, Iterable Binary trees

מבוא למדעי המחשב תרגול 10 הממשקים Iterator, Iterable Binary trees מבוא למדעי המחשב 2017 תרגול 10 הממשקים Iterator, Iterable Binary trees בתרגול היום ממשקים: Iterator Filter DynamicArrayFilterIterator עצים בינאריים. תזכורת: Iterator מידע ונתונים )data( הדרושים לתכנית

More information

else if (p.getinfo().getvotes() < c1.getvotes()) { c1 = p.getinfo()

else if (p.getinfo().getvotes() < c1.getvotes()) { c1 = p.getinfo() class BigBrother רשימה מועמדים לתחרות // candidates; private List publc void MakeVote(String name) הפעולה מקבלת שם, מוצאת את המתמודד ומוסיף לו הצבעה אחת // Node p = candidates.getfirst();

More information

Interfaces, collections and comparisons

Interfaces, collections and comparisons תכנות מונחה עצמים תרגול מספר 4 Interfaces, collections and comparisons Interfaces Overview Overview O Interface defines behavior. Overview O Interface defines behavior. O The interface includes: O Name

More information

COE 312 Data Structures. Welcome to Exam II Monday November 23, Instructor: Dr. Wissam F. Fawaz

COE 312 Data Structures. Welcome to Exam II Monday November 23, Instructor: Dr. Wissam F. Fawaz 1 COE 312 Data Structures Welcome to Exam II Monday November 23, 2016 Instructor: Dr. Wissam F. Fawaz Name: Student ID: Instructions: 1. This exam is Closed Book. Please do not forget to write your name

More information

<exp> ::= <define> <cexp> <define> ::= ( define <var-decl> <cexp> ) / DefExp(var:VarDecl, val:cexp)

<exp> ::= <define> <cexp> <define> ::= ( define <var-decl> <cexp> ) / DefExp(var:VarDecl, val:cexp) הנחיות כלליות: תאריך הבוחן: 10.5.2018 שם המרצה: מני אדלר,מיכאל אלחדד, ירון גונן מבחן בקורס: עקרונות שפות תכנות מס' קורס: 202-1-2051 מיועד לתלמידי: מדעי המחשב והנדסת תוכנה שנה: ב' סמסטר: ב' משך הבוחן: 2

More information

Programming in C תרגול 8

Programming in C תרגול 8 Programming in C תרגול 8 1 1 נושאים מצביעים רקע אופרטורים על מצביעים מצביעים כפרמטרים לפונקציה הקצאת זיכרון דינאמית Malloc free מצביעים תאור הזיכרון של המחשב: ניתן לחשוב על זיכרון המחשב כעל רצף של תאים,

More information

Midterm Spring 2015 Solutions Version 1

Midterm Spring 2015 Solutions Version 1 Version 1 1. (2 Points) In order to declare a named constant, the declaration must use which Java keyword? a. final b. int c. static d. void 2. (2 Points) Suppose c1 and c2 are objects of the class Circle.

More information

Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on

Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on Abstract Data Types - Lists Arrays implementa4on Linked- lists implementa4on Lecture 16 Jérôme Waldispühl School of Computer Science McGill University Slides by Mathieu BlancheIe Recap from last lecture

More information

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13 1 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 2 ו- HASHCODE EQUALS 3 תזכורת: המחלקה Object package

More information

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13 1 2 תוכנה 1 תרגול מספר 13 ו- HashCode Equals עוד על טיפוסים מוכללים )Advanced Generics( ו- HASHCODE EQUALS חריגים )Exceptions( בית הספר למדעי המחשב אוניברסיטת תל אביב 1 3 4 package java.lang; תזכורת: המחלקה

More information

Problems with simple variables

Problems with simple variables Problems with simple variables Hard to give up values high number of variables. Complex to sort a high number of variables by value. Impossible to use loops. Example problem: Read one hundred numbers,

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 07: Linked Lists MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Linked Lists 2 Introduction Linked List Abstract Data Type SinglyLinkedList ArrayList Keep in Mind Introduction:

More information

ב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א'

ב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כה תשרי תשעח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א' אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק א' ב- C תכנות מבחן ב: 202-1-9011 מס' הקורס : הנדסה מיועד לתלמידי : א' מועד קיץ סמ' שנה תשע"ז 3 שעות משך

More information

C Sc 227 Practice Test 2 Section Leader Name 134pts ANSWERS

C Sc 227 Practice Test 2 Section Leader Name 134pts ANSWERS C Sc 227 Practice Test 2 Section Leader Name 134pts ANSWERS 1. Determine the tightest upper bound runtimes of the following loops. Express your answer in the Big-O notation we have been using in class

More information

Lists Chapters Linked Lists Abstract Implementations Storage Leaks Ordered Lists

Lists Chapters Linked Lists Abstract Implementations Storage Leaks Ordered Lists Lists Chapters 8-11 Linked Lists Abstract Implementations Storage Leaks Ordered Lists Data Storage Organisation Three basic implementation techniques for linear data collections Files Arrays Linked Lists

More information

קורס תכנות שיעור שני: שימוש במשתנים,

קורס תכנות שיעור שני: שימוש במשתנים, קורס תכנות שיעור שני: שימוש במשתנים, בקרת זרימה, לולאות 1 נושאי השיעור היום משתנים )variables( טיפוסי משתנים בשפת C הגדרת משתנים השמה למשתנים פעולות על משתנים קליטת ערכים מהמשתמש הדפסה משתנים בקרת זרימה

More information

Vector (Java 2 Platform SE 5.0) Overview Package Class Use Tree Deprecated Index Help

Vector (Java 2 Platform SE 5.0) Overview Package Class Use Tree Deprecated Index Help Overview Package Class Use Tree Deprecated Index Help PREV CLASS NEXT CLASS FRAMES NO FRAMES All Classes SUMMARY: NESTED FIELD CONSTR METHOD DETAIL: FIELD CONSTR METHOD Página 1 de 30 Java TM 2 Platform

More information

CSE 143 Au03 Midterm 2 Page 1 of 7

CSE 143 Au03 Midterm 2 Page 1 of 7 CSE 143 Au03 Midterm 2 Page 1 of 7 Question 1. (4 points) (a) If a precondition is not true when a method is called, two possible ways to detect and handle the situation are to use an assert statement

More information

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering

Java Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering Readings and References Java Collections References» "Collections", Java tutorial» http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Winter 2003 Software Engineering http://www.cs.washington.edu/education/courses/403/03wi/

More information