עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

עזרה בjava בבקשה

Featured Replies

פורסם

אהלן, חייב חייב עזרה אשמח שתעזרו לי
שאלה בתור:
כתוב פעולה המקבלת תור que ומחזירה תור חדש שהוא היפוך סדר האיברים של התור que
עבור: que[1,2,3,4] יוחזר התור [4,3,2,1]
***ללא שימוש במבני נתונים נוספים, רמז רקורסיה***

כתוב תור חדש והסתבכתי עם זה מי שיכול לעזור לי עם היפוך לתור חדש והרקורסיה אודה לו מאוד!!smile.gif

בבקשה עזרה למתכונת הסתבכתי וכשאני רואה דרך אני מבין לפיה

 

 

אנחנו משתמשים בhead, remove וכאלה 

כלומר בNode וQueue אשמח לעזרה דחוףמאוד

פורסם

הבעיה שלך היא ב- syntax או ב"אלגוריתם"?

 

נסה משהו בכיוון הזה (זה פסאודו קוד, כמובן):

 

public Queue reverseQueue(Queue q) {
   Queue newQ = new ...
   reverseQueue(q, newQ)
   return newQ
}

// this is the recursive function
private void reverseQueue(Queue orig, Queue reversed) {
  if orig not empty {
    T element = q.remove() // first in queue
    reverseQueue(orig, reversed)
    reversed.add(element) // add to end of queue
  }
}

 

הערה: כתבת "ללא שימוש במבני נתונים נוספים, רמז רקורסיה", אבל במובן מסויים אנחנו משתמשים ב- call stack בתור מחסנית. זו כנראה סתם התחכמות, אבל כדאי שתבין מה זה ה- call stack.

 

תרגיל (בשביל לוודא שהבנת): האם חייבים תור חדש? או שאפשר לעשות את זה תוך שימוש בתור המקורי בלבד?

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.