- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
DS and Algorithm_session_03_doubly lingked list.ppt
* * * * * * * * * * Tell the students that a circular linked list can be a singly circular or a doubly circular linked list. * * * * Ask the students to write the algorithm first and then come up with the solution. * * * * * * * Tell the students that inserting a node in the middle of a circular linked list is same as that of a singly-linked list. This is because the only difference between the two lists is with the arrangement in the address field of the last node. Therefore, the process of insertion of a node at the end of the two lists is different. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide. * * * * * * * * * * * * * * * -8 8 theList 3 14 0 -1 q p(x)=3x14-8x8+6x2+2 输入多项式的项,建立多项式: 6 2 (3,14) 2 0 (-8,8) (6,2) (2,0) Output函数将多项式按降幂方式送输出流。 void Polynominal::Output(ostream out)const { int first=1; Term *p=theList-link; coutThe polynominal is:\nendl; for ( ; p!=theList; p=p-link) { if (!first (p-coef0)) out+; first=0; out*p; // 调用Term类上重载的“”操作。 } cout\nendl; } 3 14 px -8 8 2 0 6 2 0 -1 3. 多项式相加——实现q(x)?q(x)+p(x) 设p和q分别指向多项式p(x)和q(x)的当前正进行比较的项,初始 时分别指向两多项式中最高幂次的项。q1指向q的前驱结点。 对p(x)进行遍历,根据指针p、q的exp域的大小情况做相应处理: ①p-expq-exp 则q指示的项应成为结果多项式中的一项,所以q1和q右移一项。 ②p-exp==q-exp 则系数相加,即q-coef=q-coef+p-coef。如果q-coef不为零,则指 针q1和q 均右移一个结点;否则从q(x)中删除q指示的结点。 ③p-expq-exp 则复制p所指示的结点,并将其插在 q1之后。 指针p右移一项; 重复上述处理,直到p(x)中全部结点都处理完结束。 p q1 3 14 px -8 8 2 0 6 2 0 -1 q 6 12 qx 8 8 3 2 -2 6 0 -1 3 14 qx 2 10 2 0 -4 8 0 -1 一元整系数多项式相加 void Polynominal::PolyAdd(Polynominal r) //将多项式r加到多项式this上 { Term* q,*q1=theList,*p; //q1指向表头结点 p=r.theList-link; //p指向第一个要处理的结点 q=q1-link; //q1是q的前驱,p和q就指向两个当前进行比较的项 while (p-exp=0) //对r的单循环链表遍历,直到全部结点都处理完 { while (p-expq
您可能关注的文档
- 4、行政人事部职能.doc
- 4会计账项调整.ppt
- 4多媒体教学在初中生物教学中的利与弊.doc
- 4材料分析方法.ppt
- 5 分振幅法双光束干涉.ppt
- 50部最伟大的电影三部曲之文艺篇.doc
- 51单片机脉宽调制控制器外文文献及翻译.doc
- 51比饱和磁化强度.doc
- 5《情趣与兴趣》教学设计与教学反思(李洁娆).doc
- 5李明M3(参考作业).doc
- 中考地理真题练习 2024年四川省内江市中考地理真题(解析版).doc
- 中考地理真题练习 2024年河南省中考地理真题(原卷版).doc
- 中考地理真题练习 2024年四川省内江市中考地理真题(原卷版).doc
- 中考地理真题练习 2024年黑龙江省龙东地区中考地理真题(原卷版).doc
- 中考地理真题练习 2024年黑龙江省牡丹江市中考地理真题(原卷版).doc
- 中考地理真题练习 2024年甘肃省武威市临夏州中考地理真题(解析版).doc
- 中考地理真题练习 2024年甘肃省白银市中考地理真题(解析版).doc
- 中考地理真题练习 2024年湖南省中考地理真题(解析版).doc
- DB13_T2694-2018 地理标志产品 兴隆山楂.docx
- 内蒙古巴彦淖尔市2024-2025学年高一下学期期末考试生物含答案.doc
文档评论(0)