SlideServe
Menu
Préférences
© SlideServe · v2026

Understanding Big-Oh: Common APT and List Manipulation Strategies

koko avatar
9 diapositives · 232 Views · Jul 22, 2014

In this recitation, we focus on solving the Common APT using Big-Oh analysis and list manipulation techniques. You'll explore various solutions to the problem and assess their performance. By utilizing Eclipse, you'll write code to address the APT, using provided testers to validate your solutions. The session emphasizes the importance of careful iteration and management of list structures. We will also troubleshoot existing code, develop methods to enhance functionality, and share insights on efficient coding practices. Remember to collaborate, seek assistance, and submit your answers on time!

Understanding Big-Oh: Common APT and List Manipulation Strategies - slide 1
01 / 9Understanding Big-Oh: Common APT and List Manipulation Strategies
1 / 17

Télécharger la présentation

Understanding Big-Oh: Common APT and List Manipulation Strategies
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. Recitation 4 http://goo.gl/YN1BQ7 James Wei Professor Peck 1/31/2014

  2. Big-Oh

  3. Big-Oh

  4. Common APT • Go to the course APT page and read the prompt for the Common APT. • In Eclipse, write code to solve this APT. Use the tester as always to verify that your solution works. • Feel free to work with a friend. • Ask the TAs if you have any questions!

  5. Common APT • There are many different ways to solve this APT. • What are some different solutions for Common? • How do these different solutions perform (think Big O)?

  6. List Manipulation • If you haven’t already, snarf the code for Recitation 4. • Run the code for “fruit1.txt” and take note of the output and what the code is doing. • Try running the code for “fruit2.txt”. • Why doesn’t this code work? Consider: • What do the words that fail to be removed have in common? • How is the iteration index changing with each iteration?

  7. List Manipulation • Let’s fix the code. One way we can do that is by creating a new ArrayList and copying elements over into that new list. • Take some time to fix the code in Eclipse by writing a new method called removeFromListGood(). • This method should create a new ArrayList, copy over the elements we want to keep from the old list to the new one, then update the old list to be equal to the new list. • Consider: • How do we make sure we are creating a new list instead of a reference to the existing one? • How do we update the old list once we have finished making the new list?

  8. List Manipulation • How else can we fix the broken list remove code? • We can try manipulating the index as we loop through the list. • Create a new method called removeFromListIndex() that does this. As you code, consider: • What is the index at the end of each iteration? • What should the index be at the end of each iteration? • When should the index be manipulated before the next iteration begins?

  9. Have a good weekend! Don’t forget to submit your answers!