Question: COMP 2 0 1 3 Data Structures and Algorithms Programming Assignment 1 Deadline: 1 0 : 0 0 am , 2 5 ? t h

COMP2013 Data Structures and Algorithms
Programming Assignment 1
Deadline: 10:00am,25?th March, 2024
InstructionsYou can only submit one program file (either C++ or Java or Python),
and the filename must follow the format below.
Section 1: , Problem
Input: An array A[0..n-1](of comparable elements)
Output: , The total number of pairs (i,j) such that A[i]>A[j]s[x]xss[0dotssL-1]r[0dotsrL-1]s>rrsAAp=0dotsrL-1,s[p]=r[p]ks[k]>r[k]AAp=0dotsk-1s[p]=r[p]rL and AAp=0dotsrL-1,s[p]=r[p]i and A[i]>A[j].
In this problem, the input can bean array of integers oran array of strings.
(1.1) Comparison for strings
We use the lexicographical order to compare strings.
Let s[x] denote the x-th letter of the string s.
Given two strings s[0dotssL-1] and r[0dotsrL-1],
s>r holds if
ris a prefix ofs(i.e.,rL and AAp=0dotsrL-1,s[p]=r[p])OR
there exists a position k such that s[k]>r[k] and AAp=0dotsk-1s[p]=r[p]
Examples:
charge > balance
balance > bal
bbbbbb> bbbbba
(1.2) Examples for the problem
use Python
 COMP2013 Data Structures and Algorithms Programming Assignment 1 Deadline: 10:00am,25?th March,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!