Skip to content

1124626243/TheUnbreakableAlliance-lab2-2

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TheUnbreakableAlliance-lab1-8

This is lab2 report.

Variant

(2) Dynamic array

laboratory work description

• Add a new element (lst.add(3)) • Set an element with specific index / key (lst.set(1, 3)) if applicable. • Remove an element by (lst.remove(3)):

  • index for lists
  • key for dictionaries - value for sets value

• Access:

  • size (lst.size())
  • is member (lst.member(3))
  • reverse (lst.reverse() (if applicable)

• Conversion from/to built-in list :

  • from_list (lst.from_list([12, 99, 37]))
  • to_list (lst.to_list())

• Filter data structure by specific predicate (lst.filter(is_even)) • Map1 structure by specific function (lst.map(increment)) • Reduce2 – process structure elements to build a return value by specific functions(lst.reduce(sum)) • Data structure should be an iterator3 in Python style • Data structure should be a monoid and implement empty and concat methods

Project structure

  • Dynamic_array.py -- implementation of Dynamic_array class with Add_a_new_elementRemove etc.
  • Dynamic_array_test.py -- unit and PBT tests for Dynamic_array.

Features

  • map(f)
  • add(item)
  • find(key)
  • remove(key)
  • size( )
  • to_list( )
  • from_list(a)
  • filter(p)
  • map(f)
  • reduce(f, initial_state)
  • empty( )
  • concat(dict)
  • get(key)
  • member(key)
  • next( )
  • iter( )

Contribution

Changelog

  • Fan Yuxin uploaded Dynamic_array_test.py.
  • 13.04.2022 - 1
  • Wen Wenchao uploaded Dynamic_array.py.
  • 11.04.2022 - 0
    • Initial

Design notes

We create an Entry class to represent an element in the dictionary. Hash maps are used to store and find elements and open addressing is used to handle conflicts. The internal hash table has a table length of 1000.

Advantages and disadvantages of unittest

  • Advantages:
    • Support automated testing
    • Secondary development is convenient
    • Organize test cases together by class
  • Disadvantages:
    • Must be written in TestCase subclass
    • Must write test method
    • Difficult to expand

Advantages and disadvantages of PBT tests

  • Advantages:
    • Check with automatically generated input data to ensure enough test cases
    • Allows developers to increase test coverage and effectively save time
  • Disadvantages:
    • Not covering all examples

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%