Programming Fundamentals with Java U5 - UNIT 5 i...

This preview shows page 1 - 6 out of 59 pages.

i UNIT 5 Application of arrays Unit 5 TCC 121/05 Programming Fundamentals with Java Application of Arrays
Image of page 1

Subscribe to view the full document.

ii WAWASAN OPEN UNIVERSITY TCC 121/05 Programming Fundamentals with Java COURSE TEAM Course Team Coordinator: Dr. Lim Ting Yee Content Writer: Dr. Wong Li Pei Instructional Designer: Ms. Jeanne Chow Academic Member: Ms. Khor Ean Teng COURSE COORDINATOR Dr. Lim Ting Yee EXTERNAL COURSE ASSESSOR Professor Andrew Lui, The Open University of Hong Kong PRODUCTION In-house Editor: Ms. Jeanne Chow Graphic Designer: Ms. Audrey Yeong Wawasan Open University is Malaysia’s first private not-for-profit tertiary institution dedicated to adult learners. It is funded by the Wawasan Education Foundation, a tax-exempt entity established by the Malaysian People’s Movement Party (Gerakan) and supported by the Yeap Chor Ee Charitable and Endowment Trusts, other charities, corporations, members of the public and occasional grants from the Government of Malaysia. The course material development of the university is funded by Yeap Chor Ee Charitable and Endowment Trusts. © 2008 Wawasan Open University First revision 2011, Second revision 2012 Except where otherwise noted, this work is licensed under the terms of the Creative Commons Attribution-ShareAlike 3.0 Unported License. To view a copy of this license, visit http:// creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. This course material was published to support the learning of students registered with Wawasan Open University. Wawasan Open University does not grant any degree, certification or credits based solely on your completion of this course material. Wawasan Open University (KPT/JPT/DFT/US/P01) Wholly owned by Wawasan Open University Sdn. Bhd. (700364-W) 54, Jalan Sultan Ahmad Shah, 10050 Penang. Tel: (604) 2180333 Fax: (604) 2279214 Email: [email protected] Website:
Image of page 2
iii UNIT 5 Application of arrays Contents Unit 5 Application of Arrays Unit overview Unit objectives 5.1 Searching Objectives Introduction Linear search Binary search Suggested answers to activities 5.2 Sorting Objectives Introduction Insertion sort Example 1: Sorting a numeric array Example 2: Sorting a String array Suggested answers to activities Summary of Unit 5 Course summary Unit practice exercise Suggested answers to self-tests Suggested answers to unit practice exercise References 1 1 3 3 3 3 11 18 21 21 21 22 25 38 43 45 47 49 51 53 55
Image of page 3

Subscribe to view the full document.

iv WAWASAN OPEN UNIVERSITY TCC 121/05 Programming Fundamentals with Java
Image of page 4
1 UNIT 5 Application of arrays Unit Overview Y ou started programming in Java in Unit 2, where you learnt how to use class definitions to define objects to be created at runtime according to sets of attributes and behaviours they possess. At runtime, each object models a real- world object. In Unit 3, you started defining object behaviours with branching and looping so that the objects can exhibit a kind of “intelligence” and can mimic more realistic behaviours of real-world objects. In Unit 4, you learnt the use of
Image of page 5

Subscribe to view the full document.

Image of page 6
  • Winter '16
  • Wawasan Open University

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern