代写CSCI-1200作业、代做C/C++编程作业、代写Bidirectional Maps作业、C/C++课程设计作业代做
CSCI-1200 Data Structures — Fall 2018
Homework 8 — Bidirectional Maps
In this assignment you will build a custom data structure named bidirectional_map. A bidirectional_map
is similar to an STL map, in that it stores the association between key and value data. Like a map, inserting
and erasing an association between a key and a value is completed in O(log n), where n is the number of
association pairs in the map. Also, like a map, lookup by key is O(log n), but additionally, with a bidirectional
map, lookup by value is also O(log n)!
The typical implementation of an STL map stores STL pairs of the key and value in a single binary search
tree, ordered by the keys. Our bidirectional_map will instead be stored in two distinct binary search trees,
one storing the keys and one storing the values. The associations are stored as bidirectional links between
the nodes of the two trees.
The diagram below illustrates the core structure of the bidirectional_map data structure:
1
left: right:
link:
data: 3
left: right:
link:
data:
2
left: right:
link:
data:
4
left: right:
link:
data:
5
left: right:
link:
data:
6
left: right:
link:
data:
Node<int,string>
Node<int,string> Node<int,string>
Node<int,string> Node<int,string> Node<int,string>
apple fig
banana
carrot
date
eggplant
left: right:
link:
data:
left: right:
link:
data:
left: right:
link:
data:
left: right:
link:
data:
left: right:
link:
data:
left: right:
link:
data:
Node<string,int>
Node<string,int> Node<string,int>
Node<string,int>
Node<string,int>
Node<string,int>
key_root: value_root:
size:6
bidirectional_map<string,int>
Note that the bidirectional_map is templated over two types, the key type and the value type. In this
example, the key type is STL string and the value type is int. We are currently storing 6 associations in
this structure. Note that in this initial example, the associations are “one-to-one”. This means that there
are no repeated or duplicate keys or values.
Like an STL map it is not possible to edit the key of an association, because that edit may disrupt the overall
binary search ordering property of the tree. Because the values of our bidirectional_map are also stored in
their own binary search tree, we must also prohibit editing of the values in a bidirectional_map. If the key
or the value of an association needs to be changed, that data must be removed from the tree and re-inserted.
Implementation
Your task for this homework is to implement the structure diagrammed on the previous page. We recommend
that you begin your implementation by following the structure of the ds_set class we studied and worked
with in lecture and lab. You will need to make a number of significant changes to the code, but the overall
design composed of 3 classes – Node, tree_iterator, and “manager” class (bidirectional_map) – remains
the same. Note that each class is now templated over two types rather than just one.
The provided code in main.cpp illustrates the basic functionality of the bidirectional_map class including
the bidirectional_map functions: size, insert, erase (NOTE: This will be covered in Lecture 19!), find,
operator[], key_begin, key_end, value_begin, and value_end. Study these examples carefully to deduce
the expected argument and return types of the functions. The bidirectional_map has iterators over both
the keys and values, which can be incremented and decremented like regular STL iterators. Also, each
iterator’s follow_link function can be used to obtain an iterator pointing to the associated data in the
other half of the structure. You will also write a print function to help your implementation and debugging.
As this is a class with dynamically allocated memory, you will also need to implement the default constructor,
copy constructor, assignment operator, and destructor. The provided code in main.cpp does not thoroughly
test these functions, so you must write your own test cases. The homework server will compile and run your
bidirectional_map.h file with the instructor’s solution to test your implementation of these functions.
Additions/Modifications to the Core Data Structure Diagram
The Node objects illustrated in the diagram do not include parent pointers. In order to implement the
forward and backward iterators you will need to add these pointers. Alternatively, you can implement your
bidirectional_map iterators using a vector of Node pointers, as discussed in Lecture 18.
Also, for extra credit, you can extend the structure to allow many-to-one, one-to-many, and many-to-many
key/value associations. To add this feature, each node in the structure will store an STL vector of links
to Node pointers in the other tree rather than just a single Node pointer. Examples of the non-one-to-one
interface are included in the provided code.
Performance
For this assignment we will assume that the data stored in the structure is added and removed in a mostly
random fashion and that the binary tree remains sufficiently balanced so that we may claim that the maximum
height of the tree structures is not significantly greater than log n, where n is the number of associations
stored in the structure. In lecture, we will talk about algorithms for automatically rebalancing trees (but
you do not need to implement this for the homework). In your README.txt file include the big ‘O’ notation
for each of the functions described above. If you complete the implementation of non-one-to-one associations
for extra credit, you will also use k = the maximum number of links in a single Node in your answers.
Additional Testing & Homework Submission
We encourage you to work through the test cases in the provided main.cpp step-by-step, uncommenting
and debugging one test at a time. It is your responsibility to add additional test cases, including examples
where the template class key and value types are something other than string and int. Note: Your print
function is only required to work for simple types (e.g., int, double, char, and short strings). Also, your
print function is to help you debug, and does not need to exactly match the sample output. The homework
submission server is configured to run your code with Dr. Memory to search for memory problems. Your
program must be memory error free to receive full credit.http://www.daixie0.com/contents/13/1985.html
Use good coding style and comments when you design and implement your program. Please use the provided
template README.txt file for any notes you want the grader to read. You must do this assignment on
your own, as described in the “Academic Integrity for Homework” handout. If you did discuss
the assignment or debugging with anyone, please list their names in your README.txt file

因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com

微信:codinghelp

转载于:https://www.cnblogs.com/javahelper/p/9911014.html

CSCI-1200 Data Structures — Fall 2018相关推荐

  1. CSCI 1133 CSCI 1133, Fall 2018 Programming Examination

    代写CSCI 1133作业.代做Python编程作业.代写GitHub作业.代做Python程序设计作业 CSCI 1133, Fall 2018 Programming Examination 1 ...

  2. CISC-235 Fall 2018 Assignment

    代写CISC-235作业.代做Python/Java编程作业.代写C/C++课程设计作业.代做HOTNCU留学生作业 CISC-235 Fall 2018 Assignment 2 A certain ...

  3. Python_Example_ Data Structures and Algorithm Analysis 学习/示例

    Author: 楚格 2018-11-19   19:05:11 IDE: Pycharm2018.02   Python 3.7 KeyWord :  Data Structures and Alg ...

  4. Prefix Operations and Tries | CS 61B Data Structures, Spring 2019

    Data Structures Summary The problem we are presented: Given a stream of data, retrieve(搜索) informati ...

  5. CMPUT 291 (Fall 2018 LAB LEC): Mini-Project

    代写CMPUT 291作业.代做Python/Java实验设计作业.代写C/C++编程实验作业.代做File and Database作业 2018/11/4 CMPUT 291 (Fall 2018 ...

  6. pandas笔记(pandas Data Structures)

    pandas笔记(pandas Data Structures) 生信start_site已关注 32020.06.15 03:02:37字数 766阅读 509 pandas包含数据结构和数据操作工 ...

  7. python 科学计算设计_Python科学计算——Data Structures

    为什么选择Python作为科学计算语言? 有关于Matlab和Python哪个更适合作为科学计算语言的争论已久,之所以选择Python作为首选的科学计算语言,不仅仅是因为它免费,开源,有很多优秀的库和 ...

  8. Data Structures with C++ Using STL Chapter 3算法概述---笔记

    <Data Structures with C++ Using STL Chapter 3算法概述---笔记>,作者:茉莉花茶,原文链接:http://www.cnblogs.com/yc ...

  9. 20162314 《Program Design Data Structures》Learning Summary Of The First Week

    20162314 2017-2018-1 <Program Design & Data Structures>Learning Summary Of The First Week ...

最新文章

  1. 在Spring Framework中@Inject和@Autowired有什么区别? 在什么条件下使用哪一个?
  2. SpringBoot+Mybatis 实现动态数据源切换方案
  3. 1833: [ZJOI2010]count 数字计数
  4. Spring MVC+layui(基于bootstrap)+t 新增功能(页面和数据传递)
  5. adb——Android的ADB工具使用
  6. Bug--WARN Please initialize the log4j system properly.
  7. hdu 2553 N皇后问题
  8. 解决U盘插入我的电脑中不显示
  9. Android 常用抓包工具介绍之Charles
  10. 规划过程组-项目管理
  11. 车间和仓库可以一起吗_车间和仓库可以划分为一个防火分区吗
  12. 如何把苍白的一年写成耀眼的年终报告?写完当场加薪的那种
  13. 脚手架开发(1)-准备阶段
  14. 考研最后冲刺:这些要提前准备!
  15. iOS开发之定位神器-超简单方式解决iOS后台定时定位
  16. 想要改变世界的 Rust 语言
  17. 高分辨率卫星影像建筑物变化检测
  18. Python的异常及处理
  19. 程序员的奋斗史(四十一)——大学断代史(五)——我的娱乐方式
  20. 播放4K视频需要什么样的配置

热门文章

  1. Python解释器与Python编辑器的详细下载与安装过程
  2. SpringBoot整合kaptcha(谷歌验证码工具)实现验证码功能
  3. SAP HANA efashion案例(eFashion on HANA)
  4. 超分之SR-LUT源码解析
  5. 【MYSQL】一个时间是另一个时间的三分之一
  6. peakcoo分享:soc芯片
  7. CentOS7搭建XSS平台
  8. 请停用以开发者模式运行的扩展程序?搞定谷歌浏览器插件弹窗
  9. RFID 基础/分类/编码/调制/传输
  10. 程序语言功底提升的网站