4 views

Uploaded by Nguyen Kim

© All Rights Reserved

- Mã hóa kênh
- Dimrain47 - Twilight Techno (Piano)
- HD_TTTN_2009
- Giao trinh PASCAL Can Ban
- Giao Trinh Lap Trinh Huong Doi Tuong
- Lecture01 Intro
- Mã hóa nguồn
- Android Chapter04 User Interfaces
- Lap Trinh C++_trong 21 Ngay
- Bài báo
- Try 1
- CHUONG 1
- Try 1.docx
- Mophongmachlogicso
- Apis
- ontaplytthuyet_RIGA
- Lập Trình Android
- Lich Su Toan Hoc
- IOStreams-1
- LTCSDL_Phan2

You are on page 1of 4

http://elearning.epsilon-mobile.com/moodle/mod/quiz/review.php?attempt=37&showall=1 1/4

Home JWI

Junior Web Intern

You are l ogged i n as Nguyen Ki m Hi eu (Log out)

Question 1

Compl ete

Marked out of 1.00

Fl ag questi on

Information

Fl ag questi on

Question 2

Compl ete

Marked out of 1.00

Fl ag questi on

Started on Tuesday, 24 June 2014, 4:13 PM

State Finished

Completed on Tuesday, 24 June 2014, 6:09 PM

Time taken 1 hour 55 mins

Grade Not yet graded

You have two sort algorithm. How can you know which one works better?

- phc tp ca thut ton l yu t cn xt n u tin

- Tuy nhin cn ph thuc vo tng trng hp. C th mt thut ton c phc tp cao

nhng trong hon cnh ca bi ton n li ph hp hn (do khng gian phn t nh chng hn,

..) hoc c th thut gii c phc tp thp nhng hin thc kh khn v khng cn thit.

Implement a function to determine if an ANSI string (array of characters) has all unique

characters (C++ or Java). Example: abcdefghijklm -> true, aba -> false.

Additional libraries/APIs are not allowed.

Function prototype for C++ and C:

bool unique(char* str) {

}

Function prototype for Java:

bool unique(char[] str) {

}

What is the complexity of your algorithm?

bool unique(char* str) {

// Boolean array used to check out the duplication of each character

bool charArray[256];

// Initialize the array

for (int i = 0; i < 256; i++) {

charArray[i] = false;

}

// counter i

int i =0;

while (char[i] != '\0') {

// Determine the ascii value of the character

int ascii = (int)char[i];

if (charArray[ascii] != false) {

Quiz navigation

Show one page at a time

Finish review

1 i 2 3 4 5

i 6 7 8 i 9

10 11

Ngy 24 thng 6 nm 2014 Screening Test

http://elearning.epsilon-mobile.com/moodle/mod/quiz/review.php?attempt=37&showall=1 2/4

Question 4

Compl ete

Marked out of 1.00

Fl ag questi on

Question 5

Compl ete

Marked out of 1.00

Fl ag questi on

Information

Fl ag questi on

Question 6

Compl ete

Marked out of 1.00

Fl ag questi on

Question 3

Not answered

Marked out of 1.00

Fl ag questi on

return false;

} else charArray[ascii] = true;

i++;

}

return true;

}

complexity O(n). With n is the length of the string

Can you think of a linear solution? Explain your answer.

Can you use hash table (bng bm) for this problem?

C th s dng bng bm cho bi ton ny. Thut gii nh sau:

- Duyt qua tng phn t ca mng

- Xc nh kha, nu kha ny tn ti trong bng th tr v false. Ngc li, lu gi tr kha

mi ny

- Lp li cho n khi kt thc chui

* phc tp: O(n)

Can you think of an algorithm that uses sorting?

C th s dng sorting hin thc thut gii theo cc bc:

- Sp xp li chui

- Duyt qua chui v kim tra s trng lp lin tip ca cc k t

- Nu c tr v false, ngc li true.

Implement binary search algorithm (tm kim nh phn).

Function prototype for C++ and C:

bool binarySearch(int a[], int n, int value) {

// <a> is an sorted array of <n> integers.

// return true/false if <value>is inside <a>.

}

Function prototype for Java:

bool binarySearch(int[] a, int value) {

// <a> is an sorted array of integers.

// return true/false if <value> is/isnt inside <a>.

}

What is the complexity of your algorithm?

bool binarySearch(it a[], int n, int value) {

int first = 0;

int last = n - 1;

int mid = (first + last) / 2;

while (first <= last) {

if (a[mid] < value) {

Ngy 24 thng 6 nm 2014 Screening Test

http://elearning.epsilon-mobile.com/moodle/mod/quiz/review.php?attempt=37&showall=1 3/4

Question 7

Compl ete

Marked out of 1.00

Fl ag questi on

Question 8

Compl ete

Marked out of 1.00

Fl ag questi on

Information

Fl ag questi on

Question 9

Compl ete

Marked out of 1.00

Fl ag questi on

first = mid + 1;

} else if {

return true;

} else {

last = mid - 1;

}

mid = (first + last) / 2;

}

return false;

}

complexity: O(log2(n))

Let say I have an sorted array of 1 million integers, and I have 1 million integers to

search, should I use binary search? What if I have 10 million integers? What if I have only 10

integers?

Khi s tm kim qu ln th tm kim nh phn khng cn ph hp na. Nn thay th bng cch

s dng hm bm.

What is a hash table? At which condition hash table is prefered over binary search?

Bng bm l cu trc d liu lu tng cp gi tr (key, data) phc v cho vic tm kim bng

phng php bm.

Bng bm c u tin s dng khi d liu c kch thc ln cng nh s ln truy xut din

ra thng xuyn lin tc.

Implement a function that reverse every words in a string. Example: the lazy fox jumps -> eht

yzal xof spmuj. Additional libraries/APIs are not allowed.

Function prototype for C++ and C:

bool reverseWords(char* str) {

}

Function prototype for Java:

bool reverseWords(char[] str) {

}

What is the complexity of your algorithm?

bool reverseWords(char* str) {

int start = 0;

int i =0;

while (str[i] != '\0') {

if (str[i] == ' ') {

reverse(str, start, i - 1);

start = i + 1;

}

i++;

}

}

void reverse (char* a, int start, int end) {

int mid = (start + end) / 2;

int length = end - start + 1;

char temp;

Ngy 24 thng 6 nm 2014 Screening Test

http://elearning.epsilon-mobile.com/moodle/mod/quiz/review.php?attempt=37&showall=1 4/4

You are logged in as Nguyen Kim Hieu (Log out)

JWI

Question 11

Not answered

Marked out of 5.00

Fl ag questi on

Question 10

Not answered

Marked out of 1.00

Fl ag questi on

for (int i = start; i<= mid; i++) {

temp = a[i];

if (length % 2 == 0) {

a[i] = a[mid * 2 - i + 1];

a[mid * 2 - i + 1] = temp;

} else {

a[i] = a[mid * 2 - i];

a[mid * 2 - i] = temp;

}

}

}

Complexity : O(n*n)

Can you think of a linear solution?

Implement a phone management program which satisfy the following requirement:

- User can add new phone with name.

- User can look for an existing phone number in database.

- User can remove an existing record (phone + contact name) in the database.

Hint: zip your source code then attach below.

Finish review

- Mã hóa kênhUploaded bycauvonginfo
- Dimrain47 - Twilight Techno (Piano)Uploaded bydaniell1166037
- HD_TTTN_2009Uploaded byxuan tung
- Giao trinh PASCAL Can BanUploaded byJohnny8x
- Giao Trinh Lap Trinh Huong Doi TuongUploaded byĐỗ Đình Vĩnh
- Mã hóa nguồnUploaded bycauvonginfo
- Android Chapter04 User InterfacesUploaded bynguoirung16
- Lap Trinh C++_trong 21 NgayUploaded bybo kinh van
- Lecture01 IntroUploaded byLê Văn Đàn
- Bài báoUploaded bythanhluan_uit
- Try 1Uploaded byKhôi Khác
- CHUONG 1Uploaded byapi-3840901
- Try 1.docxUploaded byKhôi Khác
- MophongmachlogicsoUploaded byHuỳnh Văn Khánh
- ApisUploaded bytiendat_20791
- ontaplytthuyet_RIGAUploaded byNguyễn Chiến Công
- Lập Trình AndroidUploaded byHà Đình Tuyên
- Lich Su Toan HocUploaded byTran Nguyen Minh Tran
- IOStreams-1Uploaded byTinh Nguyen
- LTCSDL_Phan2Uploaded bynguyenvietlosptin
- BTNB Lecturer02 v2.0Uploaded byNguyen Long
- Giaxaydung.vn-gCM-Hung Yen Theo QD 114-2006-QD-UBND Ngay 28-08-2006Uploaded byNguyet Anh
- 07_lenh lo-gicUploaded byle thanh
- Chuong 07 ToantuUploaded byHồ Ngọc Hoàng
- IOStreamsUploaded byThanh Nguyen
- So Tay Lap Trinh VHDLUploaded byPhong Tran
- chuong3Uploaded bydothadung
- nullUploaded byapi-27223592
- CTDL 2005 chuong 1Uploaded bykhanh117
- Huong Dan Su DungUploaded byphamhuuluc

- Assignment 1Uploaded byNguyen Kim
- Lab2 Network ToolsUploaded byNguyen Kim
- Lab1 Network DevicesUploaded byLong Vũ
- KSTN12xettuyenbosunghk21314 (1)Uploaded byNguyen Kim
- bg_tsl_dhk2_6937Uploaded byBùi Công Huy Cường
- 2. PhieuThongTinDoanVienUploaded byNguyen Kim
- Chapter 12 - GraphUploaded byNguyen Kim
- YoutubeUploaded byNguyen Kim
- BAI SO 1Uploaded byHà Thanh Điệp
- TemplateUploaded byNguyen Kim
- Cap Phat DongUploaded byNguyen Kim
- CauHoiMau-2010-Phan1Uploaded byNguyễn Đức Toàn